From de260bd43c291376abeaa11e8cb1019e3de76f7a Mon Sep 17 00:00:00 2001 From: AarDG10 Date: Mon, 24 Aug 2026 11:08:51 +0530 Subject: [PATCH 1/2] fix(company): throw if linked to demo_company field Throws an error msg if user is deleting demo company directly. (cherry picked from commit aaa3100efc8587d7604c6794d3535a828672f70f) --- erpnext/setup/doctype/company/company.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index 05b3ce7aa7b..8d5565b3180 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -667,6 +667,13 @@ class Company(NestedSet): """ Trash accounts and cost centers for this company if no gl entry exists """ + if frappe.db.get_single_value("Global Defaults", "demo_company") == self.name: + frappe.throw( + _("{0} is the site's Demo Company and cannot be deleted directly. Use {1} instead.").format( + bold(self.name), bold(_("Delete Demo Data")) + ) + ) + NestedSet.validate_if_child_exists(self) frappe.utils.nestedset.update_nsm(self) From 3edd8ee8be6c12400de3f83010f61938c6b0acbd Mon Sep 17 00:00:00 2001 From: AarDG10 Date: Fri, 28 Aug 2026 11:48:07 +0530 Subject: [PATCH 2/2] refactor: remove bold from formatter --- erpnext/setup/doctype/company/company.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index 8d5565b3180..569d06349f4 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -670,7 +670,7 @@ class Company(NestedSet): if frappe.db.get_single_value("Global Defaults", "demo_company") == self.name: frappe.throw( _("{0} is the site's Demo Company and cannot be deleted directly. Use {1} instead.").format( - bold(self.name), bold(_("Delete Demo Data")) + self.name, _("Delete Demo Data") ) )