Trying to update Employee info gives error

Hi,

We are on the latest Master branch and encountering the error below when trying to update information on the Employee form:

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 259, in save
    return self._save(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 310, in _save
    self.run_post_save_methods()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 889, in run_post_save_methods
    self.run_method("on_update")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 757, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1026, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1009, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 751, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/hr/doctype/employee/employee.py", line 67, in on_update
    self.update_nsm_model()
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/hr/doctype/employee/employee.py", line 64, 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

Any ideas how to get around this?

Thanks

Okay, I think I may have found the cause of the issue. The Employee was reporting to another Employee who had ‘Left’ the organization. Clearing the ‘Reports To’ field seems to have solved the issue

There should be a way for the system to handle this gracefully! An Employee’s status should NOT be allowed to be changed to ‘Left’ if there are other Employees reporting to him/her

Thanks

1 Like