diff --git a/erpnext/controllers/website_list_for_contact.py b/erpnext/controllers/website_list_for_contact.py index 58349064a42c4aea7d3fff58f6b02e9cb3c66def..cf27aa117b5f43896dbd4311ae9e025cd950561c 100644 --- a/erpnext/controllers/website_list_for_contact.py +++ b/erpnext/controllers/website_list_for_contact.py @@ -301,6 +301,9 @@ def add_role_for_portal_user(portal_user, role): user_doc = frappe.get_doc("User", portal_user.user) roles = {r.role for r in user_doc.roles} + if user_doc.get("role_profile") or user_doc.get("role_profiles"): + return # It's not possible to add the Customer role + if role in roles: return diff --git a/erpnext/portal/utils.py b/erpnext/portal/utils.py index 0e4b90e682d8027f58957fcec424f68d811b3e08..e2497287b709194417e721508254ee2f8ca2209f 100644 --- a/erpnext/portal/utils.py +++ b/erpnext/portal/utils.py @@ -4,7 +4,10 @@ import frappe def set_default_role(doc, method): """Set customer, supplier, student, guardian based on email""" if frappe.flags.setting_role or frappe.flags.in_migrate: - return + return # Won't work in async task + + if doc.get("role_profile") or doc.get("role_profiles"): + return # It's not possible to add the Customer/Supplier role roles = frappe.get_roles(doc.name)