From 18d0c75f34c19bd90ca5e640dc710c219dcfb0ad Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Wed, 21 Aug 2024 11:18:26 +0530 Subject: [PATCH] fix: setup wizard breaks for non-admin user during ERPNext setup on frappehr.com domains (#2100) - hrms disables erpnext-specific roles after install. FC now logs the user in as system manager and not as an admin, so erpnext setup breaks due to missing roles - solution: move disabling roles to `setup_wizard_complete` hook (cherry picked from commit 9baf7119e5f0cbb95385b34bbaa3cf824d916d9b) --- hrms/hooks.py | 2 ++ hrms/setup.py | 2 -- hrms/subscription_utils.py | 10 ++++------ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/hrms/hooks.py b/hrms/hooks.py index eb4bb36b91..53e910e09d 100644 --- a/hrms/hooks.py +++ b/hrms/hooks.py @@ -97,6 +97,8 @@ after_install = "hrms.install.after_install" after_migrate = "hrms.setup.update_select_perm_after_install" +setup_wizard_complete = "hrms.subscription_utils.update_erpnext_access" + # Uninstallation # ------------ diff --git a/hrms/setup.py b/hrms/setup.py index 46931b32ef..737dce70a2 100644 --- a/hrms/setup.py +++ b/hrms/setup.py @@ -9,7 +9,6 @@ from frappe.installer import update_site_config from hrms.overrides.company import delete_company_fixtures -from hrms.subscription_utils import update_erpnext_access def after_install(): @@ -20,7 +19,6 @@ def after_install(): update_hr_defaults() add_non_standard_user_types() set_single_defaults() - update_erpnext_access() create_default_role_profiles() run_post_install_patches() diff --git a/hrms/subscription_utils.py b/hrms/subscription_utils.py index 2e9b45f2ea..1d0bb00d27 100644 --- a/hrms/subscription_utils.py +++ b/hrms/subscription_utils.py @@ -69,10 +69,10 @@ def subscription_updated(app: str, plan: str): update_erpnext_access() -def update_erpnext_access(): +def update_erpnext_access(user_input: dict | None): """ - ignores if user has no hrms subscription - enables erpnext workspaces and roles if user has subscribed to hrms and erpnext + Called from hooks after setup wizard completion, ignored if user has no hrms subscription + enables erpnext workspaces and roles if user has subscribed to both hrms and erpnext disables erpnext workspaces and roles if user has subscribed to hrms but not erpnext """ if not frappe.utils.get_url().endswith(".frappehr.com"): @@ -90,8 +90,6 @@ def update_erpnext_workspaces(disable: bool = True): "Accounting", "Buying", "CRM", - "ERPNext Integrations", - "ERPNext Settings", "Manufacturing", "Quality", "Selling", @@ -107,7 +105,7 @@ def update_erpnext_workspaces(disable: bool = True): workspace_doc.public = 0 if disable else 1 workspace_doc.save() except Exception: - pass + frappe.clear_messages() def update_erpnext_roles(disable: bool = True):