[hotfix] fixed the recursion error while saving the User (#8696)
This commit is contained in:
parent
c4ec937835
commit
6b3bc8a8e1
@ -4,14 +4,17 @@ def set_default_role(doc, method):
|
|||||||
'''Set customer, supplier, student based on email'''
|
'''Set customer, supplier, student based on email'''
|
||||||
if frappe.flags.setting_role or frappe.flags.in_migrate:
|
if frappe.flags.setting_role or frappe.flags.in_migrate:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
roles = frappe.get_roles(doc.name)
|
||||||
|
|
||||||
contact_name = frappe.get_value('Contact', dict(email_id=doc.email))
|
contact_name = frappe.get_value('Contact', dict(email_id=doc.email))
|
||||||
if contact_name:
|
if contact_name:
|
||||||
contact = frappe.get_doc('Contact', contact_name)
|
contact = frappe.get_doc('Contact', contact_name)
|
||||||
for link in contact.links:
|
for link in contact.links:
|
||||||
frappe.flags.setting_role = True
|
frappe.flags.setting_role = True
|
||||||
if link.link_doctype=='Customer':
|
if link.link_doctype=='Customer' and 'Customer' not in roles:
|
||||||
doc.add_roles('Customer')
|
doc.add_roles('Customer')
|
||||||
elif link.link_doctype=='Supplier':
|
elif link.link_doctype=='Supplier' and 'Supplier' not in roles:
|
||||||
doc.add_roles('Supplier')
|
doc.add_roles('Supplier')
|
||||||
elif frappe.get_value('Student', dict(student_email_id=doc.email)):
|
elif frappe.get_value('Student', dict(student_email_id=doc.email)) and 'Student' not in roles:
|
||||||
doc.add_roles('Student')
|
doc.add_roles('Student')
|
||||||
|
Loading…
Reference in New Issue
Block a user