Minor fix in creating chart of accounts based on existing (#8890)
diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py
index c7d1291..a5c551f 100644
--- a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py
+++ b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py
@@ -125,13 +125,14 @@
account_tree = {}
# fill in tree starting with root accounts (those with no parent)
- build_account_tree(account_tree, None, all_accounts)
+ if all_accounts:
+ build_account_tree(account_tree, None, all_accounts)
return account_tree
def build_account_tree(tree, parent, all_accounts):
# find children
- parent_account = parent.name if parent else None
- children = [acc for acc in all_accounts if acc.parent_account == parent_account]
+ parent_account = parent.name if parent else ""
+ children = [acc for acc in all_accounts if cstr(acc.parent_account) == parent_account]
# if no children, but a group account
if not children and parent.is_group: