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:
Shivam Mishra 2019-09-10 14:08:31 +05:30 committed by Nabin Hait
parent 88e8688a4b
commit e851346b4c
2 changed files with 17 additions and 2 deletions

View File

@ -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)
@ -104,4 +114,4 @@ def get_default_dashboards():
def get_account(account_type, company):
accounts = frappe.get_list("Account", filters={"account_type": account_type, "company": company})
if accounts:
return accounts[0].name
return accounts[0].name

View File

@ -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