ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

Can't Modify employee (Item cannot be added to its own descendents)

error

#1

I Updated to V10, I am having this message when I try to modify employee
Item cannot be added to its own descendents.


#2

Share a screen shot with the steps you are trying to do.


#3


#4

Im just saving the document. I change the photo, or change any field and this is happening. It happens in some employees, Not in all of them. Even if I only click just “save”


#5

Can you share your ERPNext and Frappe version along with browser console log?


#6

version ERPNEXT

this is the log in the browser.

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 62, in application
response = frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 22, in handle
data = execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 53, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 939, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 22, in savedocs
doc.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 256, in save
return self._save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 307, in save
self.run_post_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 887, in run_post_save_methods
self.run_method(“on_update”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 755, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1024, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1007, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 749, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/hr/doctype/employee/employee.py”, line 60, in on_update
self.update_nsm_model()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/hr/doctype/employee/employee.py”, line 57, in update_nsm_model
frappe.utils.nestedset.update_nsm(self)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/nestedset.py”, line 40, in update_nsm
update_add_node(doc, p or ‘’, pf)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/nestedset.py”, line 64, in update_add_node
validate_loop(doc.doctype, doc.name, left, right)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/nestedset.py”, line 181, in validate_loop
frappe.throw(
(“Item cannot be added to its own descendents”), NestedSetRecursionError)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 323, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 309, in msgprint
_raise_exception()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 282, in _raise_exception
raise raise_exception(encode(msg))
NestedSetRecursionError: Item cannot be added to its own descendents


#7

Any help on this topic please.!


#8

Same problem here… below is my screenshot when I updated my Employee Data…


#9

I Create an Issue on github


#10

I just bumped into this issue right now with ERPNext v10.1.72

This message resides in this function:

def validate_loop(doctype, name, lft, rgt):
"""check if item not an ancestor (loop)"""
if name in frappe.db.sql_list("""select name from `tab{0}` where lft <= %s and rgt >= %s"""
	 .format(doctype), (lft, rgt)):
	frappe.throw(_("Item cannot be added to its own descendents"), NestedSetRecursionError)

In this file:

And in the case of Employee, I cannot find where it is pulling this message from yet…


#11

I concur that this is the behavior, if you just open the employee, and make no changes at all and click Save, the same behavior occurs. I am checking into this now. It happened after an update to ERPNext v10.1.72


#12

I barely remember how to fix it. but I think that I went to the database and saw the table TabEmployee and the column lft and rgt was at “0”. I just filled with the sequence and it worked.


#13

Any update on this? Just encountered the same issue!

Kind regards,