You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When attempting to update a root record for any of the DocTypes that inherit from NestedSet, I noticed the validate method enforces that the parent field be populated with the reference/name of the root record of that entity if it exists. This prevents one from trying to update one of those records since during validation, the root record will be forced to link to itself, causing an error on a different validation_loop method later on.
Relevant log output / Stack trace / Full Error Message.
Document Insert Error
Traceback (most recent call last):
File "apps/frappe/frappe/desk/page/setup_wizard/setup_wizard.py", line 429, in make_records
doc.insert(ignore_permissions=True, ignore_if_duplicate=True)
File "apps/frappe/frappe/model/document.py", line 292, in insert
self.run_post_save_methods()
File "apps/frappe/frappe/model/document.py", line 1098, in run_post_save_methods
self.run_method("on_update")
File "apps/frappe/frappe/model/document.py", line 931, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1283, in composer
return composed(self, method, *args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1265, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File "apps/frappe/frappe/model/document.py", line 928, in fn
return method_object(*args, **kwargs)
File "apps/erpnext/erpnext/setup/doctype/sales_person/sales_person.py", line 55, in on_update
super().on_update()
File "apps/frappe/frappe/utils/nestedset.py", line 263, in on_update
update_nsm(self)
File "apps/frappe/frappe/utils/nestedset.py", line 55, in update_nsm
update_add_node(doc, parent or "", parent_field)
File "apps/frappe/frappe/utils/nestedset.py", line 77, in update_add_node
validate_loop(doc.doctype, doc.name, left, right)
File "apps/frappe/frappe/utils/nestedset.py", line 232, in validate_loop
frappe.throw(_("Item cannot be added to its own descendents"), NestedSetRecursionError)
File "apps/frappe/frappe/__init__.py", line 548, in throw
msgprint(
File "apps/frappe/frappe/__init__.py", line 509, in msgprint
_raise_exception()
File "apps/frappe/frappe/__init__.py", line 455, in _raise_exception
raise raise_exception(msg)
frappe.utils.nestedset.NestedSetRecursionError: Item cannot be added to its own descendents
The text was updated successfully, but these errors were encountered:
Information about bug
When attempting to update a root record for any of the DocTypes that inherit from NestedSet, I noticed the
validate
method enforces that theparent
field be populated with the reference/name of the root record of that entity if it exists. This prevents one from trying to update one of those records since during validation, the root record will be forced to link to itself, causing an error on a differentvalidation_loop
method later on.This is what causes other issues the community have raised in the past such as #35290, https://discuss.frappe.io/t/bench-update-11-item-cannot-be-added-to-its-own-descendents/36998/9 and #15294
Module
other
Version
both 14 and 15
Installation method
manual install
Relevant log output / Stack trace / Full Error Message.
The text was updated successfully, but these errors were encountered: