mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-05 13:24:47 +00:00
fix: do not setup charts if not setup_complete or no company found (#21670)
* fix: do not setup charts if not setup_complete or no company found Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com> * chore: remove check for setup_complete moved the check for setup_complete to frappe Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com> * chore: return an empty dict from get_data if company not set Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
This commit is contained in:
@@ -1,15 +1,22 @@
|
|||||||
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
from erpnext import get_default_company
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
def get_data():
|
def get_data():
|
||||||
return frappe._dict({
|
data = frappe._dict({
|
||||||
"dashboards": get_dashboards(),
|
"dashboards": [],
|
||||||
"charts": get_charts(),
|
"charts": []
|
||||||
})
|
})
|
||||||
|
company = get_company_for_dashboards()
|
||||||
|
if company:
|
||||||
|
company_doc = frappe.get_doc("Company", company)
|
||||||
|
data.dashboards = get_dashboards()
|
||||||
|
data.charts = get_charts(company_doc)
|
||||||
|
return data
|
||||||
|
|
||||||
def get_dashboards():
|
def get_dashboards():
|
||||||
return [{
|
return [{
|
||||||
@@ -24,8 +31,7 @@ def get_dashboards():
|
|||||||
]
|
]
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def get_charts():
|
def get_charts(company):
|
||||||
company = frappe.get_doc("Company", get_company_for_dashboards())
|
|
||||||
income_account = company.default_income_account or get_account("Income Account", company.name)
|
income_account = company.default_income_account or get_account("Income Account", company.name)
|
||||||
expense_account = company.default_expense_account or get_account("Expense Account", company.name)
|
expense_account = company.default_expense_account or get_account("Expense Account", company.name)
|
||||||
bank_account = company.default_bank_account or get_account("Bank", company.name)
|
bank_account = company.default_bank_account or get_account("Bank", company.name)
|
||||||
@@ -113,11 +119,9 @@ def get_account(account_type, company):
|
|||||||
return accounts[0].name
|
return accounts[0].name
|
||||||
|
|
||||||
def get_company_for_dashboards():
|
def get_company_for_dashboards():
|
||||||
company = frappe.defaults.get_defaults().company
|
company = get_default_company()
|
||||||
if company:
|
if not company:
|
||||||
return company
|
|
||||||
else:
|
|
||||||
company_list = frappe.get_list("Company")
|
company_list = frappe.get_list("Company")
|
||||||
if company_list:
|
if company_list:
|
||||||
return company_list[0].name
|
company = company_list[0].name
|
||||||
return None
|
return company
|
||||||
|
|||||||
Reference in New Issue
Block a user