Skip to content

Commit

Permalink
fix: setup wizard breaks for non-admin user during ERPNext setup on f…
Browse files Browse the repository at this point in the history
…rappehr.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 9baf711)
  • Loading branch information
ruchamahabal authored and mergify[bot] committed Aug 21, 2024
1 parent 6cf777d commit 18d0c75
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 2 additions & 0 deletions hrms/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ------------

Expand Down
2 changes: 0 additions & 2 deletions hrms/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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()

Expand Down
10 changes: 4 additions & 6 deletions hrms/subscription_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand All @@ -90,8 +90,6 @@ def update_erpnext_workspaces(disable: bool = True):
"Accounting",
"Buying",
"CRM",
"ERPNext Integrations",
"ERPNext Settings",
"Manufacturing",
"Quality",
"Selling",
Expand All @@ -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):
Expand Down

0 comments on commit 18d0c75

Please sign in to comment.