From 00d8dc73b90d16dec271826f0346d50ceeeaf69b Mon Sep 17 00:00:00 2001 From: Diptanil Saha Date: Wed, 12 Aug 2026 02:46:40 +0530 Subject: [PATCH] fix(coa_importer): allow importing COA through `import_coa` only for `Accounts Manager` (backport #56132) (#58064) Co-authored-by: Pratheep S --- .../chart_of_accounts_importer/chart_of_accounts_importer.py | 4 ++++ 1 file changed, 4 insertions(+) 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 eeaa5abfc6d..a50fd783d30 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 @@ -75,7 +75,10 @@ def validate_company(company): @frappe.whitelist() def import_coa(file_name, company): + frappe.only_for("Accounts Manager") + # delete existing data for accounts + frappe.has_permission("Company", "write", company, throw=True) unset_existing_data(company) # create accounts @@ -452,6 +455,7 @@ def unset_existing_data(company): fieldnames = get_linked_fields("Account").get("Company", {}).get("fieldname", []) linked = [{"fieldname": name} for name in fieldnames] update_values = {d.get("fieldname"): "" for d in linked} + frappe.db.set_value("Company", company, update_values, update_values) # remove accounts data from various doctypes