fix: not able to import chart of account if parent account is missing (#20368)
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 34070b0..362efef 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 @@
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 = {}, []