Merge pull request #19421 from rohitwaghchaure/account_not_set_for_dasboard_chart_v12

fix: 'NoneType' object is not iterable
This commit is contained in:
rohitwaghchaure 2019-10-29 11:30:22 +05:30 committed by GitHub
commit 3270ba6d8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -3,6 +3,7 @@
from __future__ import unicode_literals
import frappe, json
from frappe import _
from frappe.utils import add_to_date, date_diff, getdate, nowdate, get_last_day, formatdate
from erpnext.accounts.report.general_ledger.general_ledger import execute
from frappe.core.page.dashboard.dashboard import cache_source, get_from_date_from_timespan
@ -24,6 +25,9 @@ def get(chart_name = None, chart = None, no_cache = None, from_date = None, to_d
account = filters.get("account")
company = filters.get("company")
if not account and chart:
frappe.throw(_("Account is not set for the dashboard chart {0}").format(chart))
if not to_date:
to_date = nowdate()
if not from_date:

View File

@ -33,6 +33,10 @@ class Company(NestedSet):
return exists
def validate(self):
self.update_default_account = False
if self.is_new():
self.update_default_account = True
self.validate_abbr()
self.validate_default_accounts()
self.validate_currency()
@ -203,8 +207,8 @@ class Company(NestedSet):
"default_expense_account": "Cost of Goods Sold"
})
for default_account in default_accounts:
if self.is_new() or frappe.flags.in_test or frappe.flags.in_demo:
if self.update_default_account or frappe.flags.in_test:
for default_account in default_accounts:
self._set_default_account(default_account, default_accounts.get(default_account))
if not self.default_income_account: