System Manager can not create new role

Hi,

I can’t create new roles. following error message is coming.

"Traceback (innermost last):
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/desk/form/save.py", line 18, in savedocs
    doc.save()
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/model/document.py", line 230, in save
    self.insert()
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/model/document.py", line 208, in insert
    self.run_method("after_insert")
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/model/document.py", line 549, in run_method
    return Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/model/document.py", line 681, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/model/document.py", line 664, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/model/document.py", line 543, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/core/doctype/role/role.py", line 13, in after_insert
    frappe.get_doc("User", "Administrator").add_roles(self.name)
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/core/doctype/user/user.py", line 277, in add_roles
    self.save()
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/model/document.py", line 233, in save
    self.check_permission("write", "save")
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/model/document.py", line 140, in check_permission
    self.raise_no_permission_to(permlabel or permtype)
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/model/document.py", line 166, in raise_no_permission_to
    raise frappe.PermissionError(msg)
 PermissionError: No permission to save User Administrator
" desk.min.js:7292:94
"Traceback (innermost last):
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/app.py", line 67, in application
    response = frappe.handler.handle()
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/handler.py", line 75, in handle
    execute_cmd(cmd)
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/handler.py", line 109, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/__init__.py", line 767, in call
    return fn(*args, **newargs)
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/desk/form/save.py", line 18, in savedocs
    doc.save()
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/model/document.py", line 230, in save
    self.insert()
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/model/document.py", line 208, in insert
    self.run_method("after_insert")
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/model/document.py", line 549, in run_method
    return Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/model/document.py", line 681, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/model/document.py", line 664, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/model/document.py", line 543, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/core/doctype/role/role.py", line 13, in after_insert
    frappe.get_doc("User", "Administrator").add_roles(self.name)
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/core/doctype/user/user.py", line 277, in add_roles
    self.save()
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/model/document.py", line 233, in save
    self.check_permission("write", "save")
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/model/document.py", line 140, in check_permission
    self.raise_no_permission_to(permlabel or permtype)
  File "/home/frappe/press/benches/1510131131/apps/frappe/frappe/model/document.py", line 166, in raise_no_permission_to
    raise frappe.PermissionError(msg)
 PermissionError: No permission to save User Administrator

after testing, I found following code is causing issue.


Can anyone please confirm and give solution?

Fixed

1 Like

thanks @anand
Now its working :slight_smile: