diff --git a/frappe/core/doctype/doctype/doctype.json b/frappe/core/doctype/doctype/doctype.json index c03b2b7d99..bfa91cea75 100644 --- a/frappe/core/doctype/doctype/doctype.json +++ b/frappe/core/doctype/doctype/doctype.json @@ -45,7 +45,6 @@ "allow_events_in_timeline", "allow_auto_repeat", "make_attachments_public", - "allow_root_deletion", "view_settings", "title_field", "show_title_field_in_link", @@ -606,13 +605,6 @@ "fieldname": "make_attachments_public", "fieldtype": "Check", "label": "Make Attachments Public by Default" - }, - { - "default": "0", - "depends_on": "is_tree", - "fieldname": "allow_root_deletion", - "fieldtype": "Check", - "label": "Allow Root Deletion" } ], "icon": "fa fa-bolt", diff --git a/frappe/custom/doctype/customize_form/customize_form.json b/frappe/custom/doctype/customize_form/customize_form.json index 4a3b0aa3f2..05989eaa00 100644 --- a/frappe/custom/doctype/customize_form/customize_form.json +++ b/frappe/custom/doctype/customize_form/customize_form.json @@ -13,14 +13,12 @@ "search_fields", "column_break_5", "istable", - "is_tree", "editable_grid", "quick_entry", "track_changes", "track_views", "allow_auto_repeat", "allow_import", - "allow_root_deletion", "fields_section_break", "fields", "naming_section", @@ -339,20 +337,6 @@ "fieldname": "make_attachments_public", "fieldtype": "Check", "label": "Make Attachments Public by Default" - }, - { - "default": "0", - "fieldname": "is_tree", - "fieldtype": "Check", - "label": "Is Tree", - "read_only": 1 - }, - { - "default": "0", - "depends_on": "is_tree", - "fieldname": "allow_root_deletion", - "fieldtype": "Check", - "label": "Allow Root Deletion" } ], "hide_toolbar": 1, diff --git a/frappe/custom/doctype/customize_form/customize_form.py b/frappe/custom/doctype/customize_form/customize_form.py index 62581b8364..cacd38397a 100644 --- a/frappe/custom/doctype/customize_form/customize_form.py +++ b/frappe/custom/doctype/customize_form/customize_form.py @@ -570,8 +570,6 @@ doctype_properties = { "default_print_format": "Data", "allow_copy": "Check", "istable": "Check", - 'is_tree': 'Check', - 'allow_root_deletion': 'Check', "quick_entry": "Check", "editable_grid": "Check", "max_attachments": "Int", diff --git a/frappe/utils/nestedset.py b/frappe/utils/nestedset.py index a4b9f31402..1112b593c5 100644 --- a/frappe/utils/nestedset.py +++ b/frappe/utils/nestedset.py @@ -271,13 +271,18 @@ class NestedSet(Document): update_nsm(self) self.validate_ledger() - def on_trash(self): + def on_trash(self, allow_root_deletion=False): + """ + Runs on deletion of a document/node + + :param allow_root_deletion: used for allowing root document deletion (DEPRECATED) + """ + if not getattr(self, "nsm_parent_field", None): self.nsm_parent_field = frappe.scrub(self.doctype) + "_parent" parent = self.get(self.nsm_parent_field) - allow_root_deletion = self.meta.allow_root_deletion - if not parent and not allow_root_deletion: + if not parent and not getattr(self, "allow_root_deletion", True): frappe.throw(_("Root {0} cannot be deleted").format(_(self.doctype))) # cannot delete non-empty group