Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: setup wizard breaks for non-admin user during ERPNext setup on frappehr.com domains #2100

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading