fix(report): iterate on accounts only when accounts exist (#26391)

This commit is contained in:
Afshan 2021-07-12 11:10:28 +05:30 committed by GitHub
parent f60c3f0655
commit bf03671a33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,13 +49,12 @@ def validate_filters(filters, account_details):
if not filters.get("from_date") and not filters.get("to_date"): if not filters.get("from_date") and not filters.get("to_date"):
frappe.throw(_("{0} and {1} are mandatory").format(frappe.bold(_("From Date")), frappe.bold(_("To Date")))) frappe.throw(_("{0} and {1} are mandatory").format(frappe.bold(_("From Date")), frappe.bold(_("To Date"))))
if filters.get('account'):
filters.account = frappe.parse_json(filters.get('account'))
for account in filters.account: for account in filters.account:
if not account_details.get(account): if not account_details.get(account):
frappe.throw(_("Account {0} does not exists").format(account)) frappe.throw(_("Account {0} does not exists").format(account))
if filters.get('account'):
filters.account = frappe.parse_json(filters.get('account'))
if (filters.get("account") and filters.get("group_by") == _('Group by Account') if (filters.get("account") and filters.get("group_by") == _('Group by Account')
and account_details[filters.account].is_group == 0): and account_details[filters.account].is_group == 0):
frappe.throw(_("Can not filter based on Account, if grouped by Account")) frappe.throw(_("Can not filter based on Account, if grouped by Account"))