From d93a024ba8df99a86f3a67648c2aa99ebeb2b4ae Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Tue, 28 Apr 2026 12:44:45 +0000 Subject: [PATCH] New 'user' wizard step + drop alert toasts after setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two fixes for the noisy post-finalize popup: 1. Dedicated admin-user step The wizard was passing Frappe's existing Administrator identity (full_name="Administrator", email="admin@example.com") into setup_complete, which made Frappe's user creation suggest a new username and warn that admin@example.com had no linked employee ("İşçinin Öz Xidməti rolu silindi"). Add a new "user" step between "company" and "confirm" collecting full name, email (= login), and password (with confirmation). build_setup_args sends those values, so Frappe creates a real user with no naming clash. Administrator stays untouched as the system-of-last-resort fallback. Validation: name required, basic email regex, password ≥8 chars, passwords must match. Email "admin@example.com" / "administrator" are blocked client-side as obviously-reserved. 2. Suppress alert-style toasts At the end of materialize_after_setup, drop every entry from frappe.local.message_log where alert=1. That kills the cluster of "Sənəd X yenidən adlandırıldı" toasts that pile up when the AZ translation pipeline renames default Item Group fixtures, without silencing the genuine modal warnings (e.g. HRMS Salary Component "accounts not assigned") which use plain msgprint. --- jey_wizard/__init__.py | 2 +- jey_wizard/etaxes.py | 29 +++++++++++ jey_wizard/public/js/jey_setup.js | 81 ++++++++++++++++++++++++++++--- 3 files changed, 105 insertions(+), 7 deletions(-) diff --git a/jey_wizard/__init__.py b/jey_wizard/__init__.py index 0c5c300..74acd0e 100644 --- a/jey_wizard/__init__.py +++ b/jey_wizard/__init__.py @@ -1 +1 @@ -__version__ = "0.1.11" +__version__ = "0.1.12" diff --git a/jey_wizard/etaxes.py b/jey_wizard/etaxes.py index 8253e63..d713e2a 100644 --- a/jey_wizard/etaxes.py +++ b/jey_wizard/etaxes.py @@ -260,6 +260,14 @@ def materialize_after_setup(args): _materialize_amas_employees(company_name) + # Drop toast-style messages that piled up during the various install/translate + # stages — notably az_locale's "Sənəd X yenidən adlandırıldı" notifications + # fired when fixtures get renamed to Azerbaijani. These are cosmetic and would + # spam the post-setup screen. Modal warnings (non-alert msgprints — e.g. HRMS + # Salary Component "accounts not assigned") stay so genuine open items remain + # visible to the user. + _drop_alert_messages() + def _materialize_native_banks(company): """Create ERPNext-native Bank / GL Account / Bank Account for each non-closed @@ -758,6 +766,27 @@ def _find_default_warehouse(company): ) +def _drop_alert_messages(): + """Remove every entry from frappe.local.message_log that was queued via + frappe.msgprint(alert=True) (a.k.a. toast). Keeps non-alert msgprints so + the user still sees real warnings. + """ + try: + log = list(getattr(frappe.local, "message_log", []) or []) + except Exception: + return + if not log: + return + def _is_alert(m): + try: + if isinstance(m, dict): + return bool(m.get("alert")) + return bool(getattr(m, "alert", 0)) + except Exception: + return False + frappe.local.message_log = [m for m in log if not _is_alert(m)] + + def _only_admin(): if frappe.session.user != "Administrator": frappe.throw(_("Only Administrator may run setup"), frappe.PermissionError) diff --git a/jey_wizard/public/js/jey_setup.js b/jey_wizard/public/js/jey_setup.js index 82e2a48..75b6754 100644 --- a/jey_wizard/public/js/jey_setup.js +++ b/jey_wizard/public/js/jey_setup.js @@ -10,7 +10,7 @@ frappe.provide("jey_wizard"); // Bump this string in every commit that changes wizard code. Displayed in the badge so // we can tell at a glance which version is actually running on a given machine. Kept in // sync with __version__ in jey_wizard/__init__.py. -const JEY_WIZARD_VERSION = "0.1.11"; +const JEY_WIZARD_VERSION = "0.1.12"; // Wipe Frappe + ERPNext default slides so their `before_load`/`after_load` listeners // don't try to mutate a wizard that isn't slide-based anymore. @@ -53,6 +53,10 @@ frappe.setup.SetupWizard = class JeySetupWizard { fy_start_date: `${year}-01-01`, fy_end_date: `${year}-12-31`, valuation_method: "FIFO", + // Admin user (fresh user step — Administrator stays untouched) + user_full_name: "", + user_email: "", + user_password: "", // AMAS amas_skipped: false, amas_selected_employees: [], @@ -75,7 +79,7 @@ frappe.setup.SetupWizard = class JeySetupWizard { this.amas_verification_code = ""; this.current_step = 0; - this.steps = ["language", "asan", "employees", "company", "confirm"]; + this.steps = ["language", "asan", "employees", "company", "user", "confirm"]; this.render(); // Session arrives in whatever language Frappe booted in (usually English for @@ -121,6 +125,7 @@ frappe.setup.SetupWizard = class JeySetupWizard { else if (step === "asan") this.render_asan($body); else if (step === "employees") this.render_employees($body); else if (step === "company") this.render_company($body); + else if (step === "user") this.render_user($body); else if (step === "confirm") this.render_confirm($body); this.render_nav($nav, step); @@ -514,6 +519,38 @@ frappe.setup.SetupWizard = class JeySetupWizard { return initialsOf(clean, 4).slice(0, 10); } + render_user($body) { + // Collect a real admin user separate from Frappe's Administrator. We + // pass full_name/email/password into setup_complete; Frappe will create + // this user during run_setup_success. Administrator itself stays as + // the system-of-last-resort fallback login. + $body.html(` +
${__("Create the day-to-day admin account. The default Administrator login is preserved as a fallback.")}
+