fix: dont make dashboards if company is not set (#18975)
* fix: dont make dashboardss if company is not set * fix: function call * Update dashboard_charts.py
This commit is contained in:
parent
88e8688a4b
commit
e851346b4c
@ -3,8 +3,18 @@ from frappe import _
|
||||
import frappe
|
||||
import json
|
||||
|
||||
def get_company_for_dashboards():
|
||||
company = frappe.defaults.get_defaults().company
|
||||
if company:
|
||||
return company
|
||||
else:
|
||||
company_list = frappe.get_list("Company")
|
||||
if company_list:
|
||||
return company_list[0].name
|
||||
return None
|
||||
|
||||
def get_default_dashboards():
|
||||
company = frappe.get_doc("Company", frappe.defaults.get_defaults().company)
|
||||
company = frappe.get_doc("Company", get_company_for_dashboards())
|
||||
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)
|
||||
bank_account = company.default_bank_account or get_account("Bank", company.name)
|
||||
|
@ -501,6 +501,11 @@ def install_defaults(args=None):
|
||||
make_records(records)
|
||||
|
||||
def add_dashboards():
|
||||
from erpnext.setup.setup_wizard.data.dashboard_charts import get_company_for_dashboards
|
||||
|
||||
if not get_company_for_dashboards():
|
||||
return
|
||||
|
||||
from erpnext.setup.setup_wizard.data.dashboard_charts import get_default_dashboards
|
||||
from frappe.modules.import_file import import_file_by_path
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user