From f71cb8dc6db03ee5ddc50aac58ef52b4fc783c71 Mon Sep 17 00:00:00 2001 From: Zlash65 Date: Wed, 13 Feb 2019 16:32:04 +0530 Subject: [PATCH] fix: return if no descendants found --- erpnext/accounts/doctype/account/account.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index dea82d8ed6..e241fc4a3a 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -101,9 +101,10 @@ class Account(NestedSet): frappe.throw(_("Please add the account to root level Company - %s" % ancestors[0])) else: descendants = get_descendants_of('Company', self.company) - acc_name = frappe.db.get_value('Account', self.parent_account, "account_name") + if not descendants: return acc_name_map = {} + acc_name = frappe.db.get_value('Account', self.parent_account, "account_name") for d in frappe.db.get_values('Account', {"company": ["in", descendants], "account_name": acc_name}, ["company", "name"], as_dict=True):