From 0166f69b319c1a6722324f3316a47ade77de76f0 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 7 Jun 2023 15:09:49 +0530 Subject: [PATCH] chore: extend default role profiles --- erpnext/setup/install.py | 42 ++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py index 28e5e5cdd2..1d5428a40e 100644 --- a/erpnext/setup/install.py +++ b/erpnext/setup/install.py @@ -206,13 +206,39 @@ def hide_workspaces(): def create_default_role_profiles(): - for module in ["Accounts", "Stock", "Manufacturing"]: - create_role_profile(module) + for role_profile_name, roles in DEFAULT_ROLE_PROFILES.items(): + role_profile = frappe.new_doc("Role Profile") + role_profile.role_profile = role_profile_name + for role in roles: + role_profile.append("roles", {"role": role}) + + role_profile.insert(ignore_permissions=True) -def create_role_profile(module): - role_profile = frappe.new_doc("Role Profile") - role_profile.role_profile = _("{0} User").format(module) - role_profile.append("roles", {"role": module + " User"}) - role_profile.append("roles", {"role": module + " Manager"}) - role_profile.insert() +DEFAULT_ROLE_PROFILES = { + "Inventory": [ + "Stock User", + "Stock Manager", + "Item Manager", + ], + "Manufacturing": [ + "Stock User", + "Manufacturing User", + "Manufacturing Manager", + ], + "Accounts": [ + "Accounts User", + "Accounts Manager", + ], + "Sales": [ + "Sales User", + "Stock User", + "Sales Manager", + ], + "Purchase": [ + "Item Manager", + "Stock User", + "Purchase User", + "Purchase Manager", + ], +}