From 3ca3fc525d89f42ff1a2bc2380f5f979cb0be7d7 Mon Sep 17 00:00:00 2001 From: aakvatech <35020381+aakvatech@users.noreply.github.com> Date: Sun, 23 Aug 2026 12:58:55 +0300 Subject: [PATCH 1/3] fix: avoid monkey patch loading without site context --- csf_tz/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/csf_tz/__init__.py b/csf_tz/__init__.py index 95acbb0d..3f1c0388 100755 --- a/csf_tz/__init__.py +++ b/csf_tz/__init__.py @@ -19,11 +19,17 @@ def load_monkey_patches(): if patches_loaded: return - patches_loaded = True + # Bench-level commands such as asset builds can run without a site context. + # Avoid querying installed apps in that case, because it attempts a database + # connection and fails with "site must be fully initialized, db_name missing". + if not getattr(frappe.local, "site", None): + return if app_name not in frappe.get_installed_apps(): return + patches_loaded = True + for module_name in os.listdir(frappe.get_app_path(app_name, "monkey_patches")): if not module_name.endswith(".py") or module_name == "__init__.py": continue From a25700f178558cae8fbf163874ba7eff0e1603f3 Mon Sep 17 00:00:00 2001 From: aakvatech <35020381+aakvatech@users.noreply.github.com> Date: Sun, 23 Aug 2026 13:05:34 +0300 Subject: [PATCH 2/3] fix: use dedicated group for multicurrency bank charges --- csf_tz/setup_data/accounts.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/csf_tz/setup_data/accounts.json b/csf_tz/setup_data/accounts.json index 1e542ea8..41c998cd 100644 --- a/csf_tz/setup_data/accounts.json +++ b/csf_tz/setup_data/accounts.json @@ -31,7 +31,7 @@ }, { "doctype": "Account", - "account_name": "Bank Charges", + "account_name": "Bank Charges Accounts", "company": "{company}", "account_currency": "TZS", "parent_account": "Financial Charges - {abbr}", @@ -147,7 +147,7 @@ "account_name": "Bank Charges TZS", "company": "{company}", "account_currency": "TZS", - "parent_account": "Bank Charges - {abbr}", + "parent_account": "Bank Charges Accounts - {abbr}", "root_type": "Expense", "report_type": "Profit and Loss" }, From 57659c72c3756a527d477dd2afd1f8d34f854f60 Mon Sep 17 00:00:00 2001 From: av-dev2 Date: Sun, 23 Aug 2026 13:11:51 +0300 Subject: [PATCH 3/3] fix: skip monkey patch loading in site-less contexts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The patched frappe.get_hooks loads monkey patches on every call, which triggers frappe.get_installed_apps() and forces a DB connection. In site-less contexts like `bench build`, no site is bound, so connect() fails with "site must be fully initialized, db_name missing" — breaking app installation during the asset build step. Bail out of load_monkey_patches() when frappe.local.site is not set, before marking patches as loaded, so the patched frappe.connect still loads them once a real site connection is established. --- csf_tz/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/csf_tz/__init__.py b/csf_tz/__init__.py index 95acbb0d..78d76dfa 100755 --- a/csf_tz/__init__.py +++ b/csf_tz/__init__.py @@ -19,6 +19,11 @@ def load_monkey_patches(): if patches_loaded: return + # Site-less contexts (`bench build`, etc.) must not force a DB + # connection; the frappe.connect patch loads these later anyway. + if not getattr(frappe.local, "site", None): + return + patches_loaded = True if app_name not in frappe.get_installed_apps():