bypass root node validation if no parent found
This commit is contained in:
parent
a9107d5f28
commit
634e3f3dbb
1 changed files with 2 additions and 2 deletions
|
|
@ -185,12 +185,12 @@ class NestedSet(Document):
|
|||
update_nsm(self)
|
||||
self.validate_ledger()
|
||||
|
||||
def on_trash(self):
|
||||
def on_trash(self, allow_root_deletion=False):
|
||||
if not getattr(self, 'nsm_parent_field', None):
|
||||
self.nsm_parent_field = frappe.scrub(self.doctype) + "_parent"
|
||||
|
||||
parent = self.get(self.nsm_parent_field)
|
||||
if not parent:
|
||||
if not parent and not allow_root_deletion:
|
||||
frappe.throw(_("Root {0} cannot be deleted").format(_(self.doctype)))
|
||||
|
||||
# cannot delete non-empty group
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue