From 6511eb4c7c4fbda1c4b4b274e47b5940d3572a45 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 24 Jun 2025 14:51:15 +0530 Subject: [PATCH] refactor: track completed app setup wizards and re-run the setup wizard upon new app installation. (backport #47691) (#48223) * refactor: track completed app setup wizards and re-run the setup wizard upon new app installation. (#47691) (cherry picked from commit 75b5ba6e67d61f8ec1554a6fb922d086d1cc299d) # Conflicts: # erpnext/hooks.py # erpnext/setup/install.py * chore: fix conflicts * chore: fix conflicts * chore: fix conflicts * fix: permission issue * fix: space --------- Co-authored-by: rohitwaghchaure --- erpnext/hooks.py | 1 - erpnext/public/js/setup_wizard.js | 11 +++++++++-- erpnext/setup/install.py | 7 ------- .../setup/setup_wizard/operations/install_fixtures.py | 1 + erpnext/utilities/activation.py | 3 ++- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 21f301f2450..db9408b0f7e 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -57,7 +57,6 @@ setup_wizard_complete = "erpnext.setup.setup_wizard.setup_wizard.setup_demo" setup_wizard_test = "erpnext.setup.setup_wizard.test_setup_wizard.run_setup_wizard_test" before_install = [ - "erpnext.setup.install.check_setup_wizard_not_completed", "erpnext.setup.install.check_frappe_version", ] after_install = "erpnext.setup.install.after_install" diff --git a/erpnext/public/js/setup_wizard.js b/erpnext/public/js/setup_wizard.js index 20fdbcd9b13..934e58f189e 100644 --- a/erpnext/public/js/setup_wizard.js +++ b/erpnext/public/js/setup_wizard.js @@ -8,6 +8,13 @@ frappe.pages["setup-wizard"].on_page_load = function (wrapper) { }; frappe.setup.on("before_load", function () { + if ( + frappe.boot.setup_wizard_completed_apps?.length && + frappe.boot.setup_wizard_completed_apps.includes("erpnext") + ) { + return; + } + erpnext.setup.slides_settings.map(frappe.setup.add_slide); }); @@ -96,7 +103,7 @@ erpnext.setup.slides_settings = [ }, set_fy_dates: function (slide) { - var country = frappe.wizard.values.country; + var country = frappe.wizard.values.country || frappe.defaults.get_default("country"); if (country) { let fy = erpnext.setup.fiscal_years[country]; @@ -118,7 +125,7 @@ erpnext.setup.slides_settings = [ }, load_chart_of_accounts: function (slide) { - let country = frappe.wizard.values.country; + let country = frappe.wizard.values.country || frappe.defaults.get_default("country"); if (country) { frappe.call({ diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py index b15925ea232..d5f2c5422bd 100644 --- a/erpnext/setup/install.py +++ b/erpnext/setup/install.py @@ -39,13 +39,6 @@ def after_install(): frappe.db.commit() -def check_setup_wizard_not_completed(): - if cint(frappe.db.get_single_value("System Settings", "setup_complete") or 0): - message = """ERPNext can only be installed on a fresh site where the setup wizard is not completed. -You can reinstall this site (after saving your data) using: bench --site [sitename] reinstall""" - frappe.throw(message) # nosemgrep - - def check_frappe_version(): def major_version(v: str) -> str: return v.split(".")[0] diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py index 0077a214e67..9cdf24cf451 100644 --- a/erpnext/setup/setup_wizard/operations/install_fixtures.py +++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py @@ -504,6 +504,7 @@ def update_stock_settings(): stock_settings.auto_insert_price_list_rate_if_missing = 1 stock_settings.update_price_list_based_on = "Rate" stock_settings.set_qty_in_transactions_based_on_serial_no_input = 1 + stock_settings.flags.ignore_permissions = True stock_settings.save() diff --git a/erpnext/utilities/activation.py b/erpnext/utilities/activation.py index 5a72f13b4a5..e09d87dd769 100644 --- a/erpnext/utilities/activation.py +++ b/erpnext/utilities/activation.py @@ -4,6 +4,7 @@ import frappe from frappe import _ +from frappe.core.doctype.installed_applications.installed_applications import get_setup_wizard_completed_apps import erpnext @@ -45,7 +46,7 @@ def get_level(): activation_level += 1 sales_data.append({doctype: count}) - if frappe.db.get_single_value("System Settings", "setup_complete"): + if "erpnext" in get_setup_wizard_completed_apps(): activation_level += 1 communication_number = frappe.db.count("Communication", dict(communication_medium="Email"))