From aa9d5640c0ac10470b79623e2682fa61a8be28c5 Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Fri, 27 Mar 2026 17:04:35 +0400 Subject: [PATCH] remove broken account_tree_custom.js, fix COA balance offset Removed account_tree_custom.js which caused console errors due to accessing undefined treeview fields. Export functionality is already available via account_list.js. Added CSS fix for Chart of Accounts tree view where account balances were visually shifted down by one row due to float:right on balance-area. Fix uses flexbox on tree nodes instead. Co-Authored-By: Claude Opus 4.6 (1M context) --- jey_erp/hooks.py | 3 +- jey_erp/public/css/account_tree_fix.css | 13 +++++++ jey_erp/public/js/account_tree_custom.js | 44 ------------------------ 3 files changed, 14 insertions(+), 46 deletions(-) create mode 100644 jey_erp/public/css/account_tree_fix.css delete mode 100644 jey_erp/public/js/account_tree_custom.js diff --git a/jey_erp/hooks.py b/jey_erp/hooks.py index 0a4915d..8d8f352 100644 --- a/jey_erp/hooks.py +++ b/jey_erp/hooks.py @@ -10,7 +10,6 @@ boot_session = "jey_erp.extend_party_types.add_company_to_party_account_types" app_include_js = [ "/assets/jey_erp/js/vat_calculator.js", - "/assets/jey_erp/js/account_tree_custom.js", "/assets/jey_erp/js/sales_invoice.js", "/assets/jey_erp/js/sales_invoice_vat.js", "/assets/jey_erp/js/sales_order_vat.js", @@ -19,11 +18,11 @@ app_include_js = [ app_include_css = [ "/assets/jey_erp/css/bank_reconciliation_tool.css", + "/assets/jey_erp/css/account_tree_fix.css", ] doctype_js = { "Payment Entry": "/public/js/payment_entry_mod.js", - "Account": "/public/js/account_tree_custom.js", "Sales Invoice": "public/js/sales_invoice.js", "Employee": "public/js/employee.js", "Bank Reconciliation Tool": "public/js/bank_reconciliation_tool.js", diff --git a/jey_erp/public/css/account_tree_fix.css b/jey_erp/public/css/account_tree_fix.css new file mode 100644 index 0000000..ba95925 --- /dev/null +++ b/jey_erp/public/css/account_tree_fix.css @@ -0,0 +1,13 @@ +.tree li { + display: flex; + flex-wrap: wrap; + align-items: center; +} + +.balance-area { + margin-left: auto; +} + +.tree-children { + flex-basis: 100%; +} diff --git a/jey_erp/public/js/account_tree_custom.js b/jey_erp/public/js/account_tree_custom.js deleted file mode 100644 index b87ffc8..0000000 --- a/jey_erp/public/js/account_tree_custom.js +++ /dev/null @@ -1,44 +0,0 @@ -frappe.provide("frappe.treeview_settings"); - -function _download_chart_of_accounts() { - frappe.call({ - method: "jey_erp.custom.account_export.export_chart_of_accounts", - callback: function (r) { - if (!r.message) return; - const json = JSON.stringify(r.message, null, 2); - const blob = new Blob([json], { type: "application/json" }); - const url = URL.createObjectURL(blob); - const a = document.createElement("a"); - a.href = url; - a.download = "az_chart_of_accounts.json"; - a.click(); - URL.revokeObjectURL(url); - }, - }); -} - -frappe.treeview_settings["Account"] = frappe.treeview_settings["Account"] || {}; -frappe.treeview_settings["Account"].onload = function (treeview) { - treeview.page.add_inner_button(__("Export Chart of Accounts"), function () { - _download_chart_of_accounts(); - }); -}; - -// Сохраняем оригинальные поля -var original_fields = frappe.treeview_settings["Account"].fields; - -// Переопределяем массив полей, добавляя наши новые поля -frappe.treeview_settings["Account"].fields = original_fields.concat([ - { - fieldtype: "Check", - fieldname: "is_account", - label: __("Is Account"), - description: __("Check if this is a regular account") - }, - { - fieldtype: "Check", - fieldname: "is_sub_account", - label: __("Is Sub Account"), - description: __("Check if this is a sub account") - } -]); \ No newline at end of file