From d14a6c058a8eadf91f80c5a8fff1b42dfc518787 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 17 Jan 2017 18:46:37 +0530 Subject: [PATCH] [fix] stop recursion while adding role --- erpnext/utilities/address_and_contact.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/erpnext/utilities/address_and_contact.py b/erpnext/utilities/address_and_contact.py index f3435aeed4..12ceb5b61b 100644 --- a/erpnext/utilities/address_and_contact.py +++ b/erpnext/utilities/address_and_contact.py @@ -36,10 +36,13 @@ def load_address_and_contact(doc, key): def set_default_role(doc, method): '''Set customer, supplier, student based on email''' + if frappe.flags.setting_role: + return 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': doc.add_roles('Customer') elif link.link_doctype=='Supplier':