fix(company): throw if linked to demo_company field

Throws an error msg if user is deleting demo company directly.

(cherry picked from commit aaa3100efc)
This commit is contained in:
AarDG10
2026-08-24 11:08:51 +05:30
committed by Mergify
parent 9e082a96f7
commit de260bd43c

View File

@@ -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)