From 87fe2143bee4ac4ada6152b35ba348110c1e6c26 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Tue, 21 Jan 2020 15:32:12 +0530 Subject: [PATCH] fix: not able to import chart of account if parent account is missing (#20367) --- .../chart_of_accounts_importer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py index 9bf5887b38f..7f51b139de4 100644 --- a/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py +++ b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py @@ -96,7 +96,11 @@ def build_forest(data): if parent_account == account_name == child: return [parent_account] elif account_name == child: - return [child] + return_parent(data, parent_account) + parent_account_list = return_parent(data, parent_account) + if not parent_account_list: + frappe.throw(_("The parent account {0} does not exists") + .format(parent_account)) + return [child] + parent_account_list charts_map, paths = {}, []