fix: Ignore perms when updating role profile from customer group on contact save
Traceback with variables (most recent call last):
File "apps/frappe/frappe/utils/background_jobs.py", line 235, in execute_job
retval = method(**kwargs)
site = 'example.dokos.cloud'
method = <function create_contact>
event = None
job_name = 'frappe.core.doctype.user.user.create_contact'
kwargs = {'user': <User: user@example.org>, 'ignore_mandatory': True, 'ignore_links': True}
user = 'ex-system-manager@example.org'
is_async = True
retry = 0
retval = None
method_name = 'frappe.core.doctype.user.user.create_contact'
actual_func_name = 'frappe.core.doctype.user.user.create_contact'
before_job_task = 'frappe.monitor.start'
e = PermissionError()
File "apps/frappe/frappe/core/doctype/user/user.py", line 1403, in create_contact
contact.save(ignore_permissions=True)
user = <User: user@example.org>
ignore_links = True
ignore_mandatory = True
get_contact_name = <function get_contact_name>
contact_name = 'John Doe'
contact = <Contact: John Doe>
File "apps/frappe/frappe/model/document.py", line 343, in save
return self._save(*args, **kwargs)
self = <Contact: John Doe>
args = ()
kwargs = {'ignore_permissions': True}
File "apps/frappe/frappe/model/document.py", line 416, in _save
self.run_post_save_methods()
self = <Contact: John Doe>
ignore_permissions = True
ignore_version = None
File "apps/frappe/frappe/model/document.py", line 1201, in run_post_save_methods
self.run_method("on_update")
self = <Contact: John Doe>
File "apps/frappe/frappe/model/document.py", line 1019, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
self = <Contact: John Doe>
method = 'on_update'
args = ()
kwargs = {}
fn = <function Document.run_method.<locals>.fn>
File "apps/frappe/frappe/model/document.py", line 1412, in composer
return composed(self, method, *args, **kwargs)
self = <Contact: John Doe>
args = ()
kwargs = {}
hooks = [<function update_contacts_to_google_contacts>, <function update_contact_user_roles>, <function clear_doctype_notifications>, <function process_workflow_actions>, <function attach_files_to_document>, <function apply>, <function update_due_date>, <function apply_permissions_for_non_standard_user_type>, <function make_perm_log>]
method = 'on_update'
doc_events = {'*': {'on_update': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions', 'frappe.core.doctype.file.utils.attach_files_to_document', 'frappe.automation.doctype.assignment_rule.assignment_rule.apply', 'frappe.automation.doctype.assignment_rule.assignment_rule.update_due_date', 'frappe.core.doctype.user_type.user_type.apply_permissions_for_non_standard_user_type', 'frappe.core.doctype.permission_log.permission_log.make_perm_log'], 'after_rename': ['frappe.desk.notifications.clear_doctype_notifications'], 'on_cancel': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions', 'frappe.automation.doctype.assignment_rule.assignment_rule.apply'], 'on_trash': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions'], 'on_update_after_submit': ...
handler = 'frappe.core.doctype.permission_log.permission_log.make_perm_log'
composed = <function Document.hook.<locals>.compose.<locals>.runner>
compose = <function Document.hook.<locals>.compose>
f = <function Document.run_method.<locals>.fn>
File "apps/frappe/frappe/model/document.py", line 1396, in runner
add_to_return_value(self, f(self, method, *args, **kwargs))
self = <Contact: John Doe>
method = 'on_update'
args = ()
kwargs = {}
f = <function update_contact_user_roles>
add_to_return_value = <function Document.hook.<locals>.add_to_return_value>
fn = <function Document.run_method.<locals>.fn>
hooks = (<function update_contacts_to_google_contacts>, <function update_contact_user_roles>, <function clear_doctype_notifications>, <function process_workflow_actions>, <function attach_files_to_document>, <function apply>, <function update_due_date>, <function apply_permissions_for_non_standard_user_type>, <function make_perm_log>)
File "apps/erpnext/erpnext/portal/utils.py", line 152, in update_contact_user_roles
update_linked_user("Customer", customer, doc)
doc = <Contact: John Doe>
method = 'on_update'
supplier = None
customer = 'John Doe'
File "apps/erpnext/erpnext/portal/utils.py", line 173, in update_linked_user
update_role_profile(user, role_profile)
doctype = 'Customer'
docname = 'John Doe'
doc = <Contact: John Doe>
get_linked_user = <function update_linked_user.<locals>.get_linked_user>
update_role_profile = <function update_linked_user.<locals>.update_role_profile>
user = <User: user@example.org>
dt_has_field = False
link_group = 'Resident'
role_profile = 'The Role Profile'
File "apps/erpnext/erpnext/portal/utils.py", line 162, in update_role_profile
user.save()
user = <User: user@example.org>
role_profile = 'The Role Profile'
File "apps/frappe/frappe/model/document.py", line 343, in save
return self._save(*args, **kwargs)
self = <User: user@example.org>
args = ()
kwargs = {}
File "apps/frappe/frappe/model/document.py", line 369, in _save
self.check_permission("write", "save")
self = <User: user@example.org>
ignore_permissions = None
ignore_version = None
File "apps/frappe/frappe/model/document.py", line 220, in check_permission
self.raise_no_permission_to(permtype)
self = <User: user@example.org>
permtype = 'write'
permlevel = 'save'
File "apps/frappe/frappe/model/document.py", line 243, in raise_no_permission_to
raise frappe.PermissionError
self = <User: user@example.org>
perm_type = 'write'
frappe.exceptions.PermissionError:
Edited by Corentin Forler