mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-12 19:35:09 +00:00
Merge pull request #50037 from frappe/mergify/bp/version-15-hotfix/pr-50034
fix: set default roles on Role Profiles during reinstallation (backport #50034)
This commit is contained in:
@@ -262,6 +262,20 @@ def update_roles():
|
||||
|
||||
def create_default_role_profiles():
|
||||
for role_profile_name, roles in DEFAULT_ROLE_PROFILES.items():
|
||||
if frappe.db.exists("Role Profile", role_profile_name):
|
||||
role_profile = frappe.get_doc("Role Profile", role_profile_name)
|
||||
existing_roles = [row.role for row in role_profile.roles]
|
||||
|
||||
role_profile.roles = [row for row in role_profile.roles if row.role in roles]
|
||||
|
||||
for role in roles:
|
||||
if role not in existing_roles:
|
||||
role_profile.append("roles", {"role": role})
|
||||
|
||||
role_profile.save(ignore_permissions=True)
|
||||
|
||||
continue
|
||||
|
||||
role_profile = frappe.new_doc("Role Profile")
|
||||
role_profile.role_profile = role_profile_name
|
||||
for role in roles:
|
||||
|
||||
Reference in New Issue
Block a user