From 4a83b0812f3a04c4c12b7b0202a10e123abd92fd Mon Sep 17 00:00:00 2001 From: Corentin Forler Date: Thu, 31 Jul 2025 16:46:12 +0200 Subject: [PATCH] fix(user): Don't append Customer/Supplier role if user has profile --- erpnext/controllers/website_list_for_contact.py | 3 +++ erpnext/portal/utils.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/erpnext/controllers/website_list_for_contact.py b/erpnext/controllers/website_list_for_contact.py index 58349064a4..cf27aa117b 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 0e4b90e682..e2497287b7 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) -- GitLab