From c2ad5d0fc7e7e828631158858cc84ef9ab3e2243 Mon Sep 17 00:00:00 2001 From: Lakshit Jain <108322669+ljain112@users.noreply.github.com> Date: Mon, 11 Aug 2025 17:07:03 +0530 Subject: [PATCH] Merge pull request #49093 from ljain112/fix-account-coa fix: allow creation of root accounts in account tree view (cherry picked from commit d45cd5af2bee982b069a8288db74c6314a7c508c) --- erpnext/accounts/doctype/account/account.py | 6 +++--- erpnext/accounts/doctype/account/account_tree.js | 7 +------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index b9cde43653a..f81afbd1297 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -169,7 +169,7 @@ class Account(NestedSet): if par.root_type: self.root_type = par.root_type - if self.is_group: + if cint(self.is_group): db_value = self.get_doc_before_save() if db_value: if self.report_type != db_value.report_type: @@ -212,7 +212,7 @@ class Account(NestedSet): if doc_before_save and not doc_before_save.parent_account: throw(_("Root cannot be edited."), RootNotEditable) - if not self.parent_account and not self.is_group: + if not self.parent_account and not cint(self.is_group): throw(_("The root account {0} must be a group").format(frappe.bold(self.name))) def validate_root_company_and_sync_account_to_children(self): @@ -261,7 +261,7 @@ class Account(NestedSet): if self.check_gle_exists(): throw(_("Account with existing transaction cannot be converted to ledger")) - elif self.is_group: + elif cint(self.is_group): if self.account_type and not self.flags.exclude_account_type_check: throw(_("Cannot covert to Group because Account Type is selected.")) elif self.check_if_child_exists(): diff --git a/erpnext/accounts/doctype/account/account_tree.js b/erpnext/accounts/doctype/account/account_tree.js index 84b6239a392..1687466096c 100644 --- a/erpnext/accounts/doctype/account/account_tree.js +++ b/erpnext/accounts/doctype/account/account_tree.js @@ -252,10 +252,6 @@ frappe.treeview_settings["Account"] = { root_company, ]); } else { - const node = treeview.tree.get_selected_node(); - if (node.is_root) { - frappe.throw(__("Cannot create root account.")); - } treeview.new_node(); } }, @@ -274,8 +270,7 @@ frappe.treeview_settings["Account"] = { ].treeview.page.fields_dict.root_company.get_value() || frappe.flags.ignore_root_company_validation) && node.expandable && - !node.hide_add && - !node.is_root + !node.hide_add ); }, click: function () {