From 6b3bc8a8e1edf8fbae79f8f960f953823adace84 Mon Sep 17 00:00:00 2001 From: Makarand Bauskar Date: Fri, 5 May 2017 11:53:00 +0530 Subject: [PATCH] [hotfix] fixed the recursion error while saving the User (#8696) --- erpnext/portal/utils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/erpnext/portal/utils.py b/erpnext/portal/utils.py index 7dffd03341..8115c1fb9b 100644 --- a/erpnext/portal/utils.py +++ b/erpnext/portal/utils.py @@ -4,14 +4,17 @@ def set_default_role(doc, method): '''Set customer, supplier, student based on email''' if frappe.flags.setting_role or frappe.flags.in_migrate: return + + roles = frappe.get_roles(doc.name) + contact_name = frappe.get_value('Contact', dict(email_id=doc.email)) if contact_name: contact = frappe.get_doc('Contact', contact_name) for link in contact.links: frappe.flags.setting_role = True - if link.link_doctype=='Customer': + if link.link_doctype=='Customer' and 'Customer' not in roles: doc.add_roles('Customer') - elif link.link_doctype=='Supplier': + elif link.link_doctype=='Supplier' and 'Supplier' not in roles: 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')