diff --git a/erpnext/controllers/website_list_for_contact.py b/erpnext/controllers/website_list_for_contact.py index 31578555e6cd23a645269bee5f571597dcba2c9f..59cf6f2decf0c491fd1baaa323121d6ea57c4f1a 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 aed6cfb283c6943704127a59bf0e0d5ff19ccf19..1d74335854c9372cefdae393837c01c454365828 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)