From ac4a5bfe6d5d08735dbf2745ca5f2ed7b138ea9d Mon Sep 17 00:00:00 2001 From: l0gesh29 Date: Fri, 8 Aug 2025 14:20:25 +0530 Subject: [PATCH 1/6] fix: add fieldname in accounting dimension filter (cherry picked from commit ac2acc535d9742622b1733dbe7f93db2a4450032) # Conflicts: # erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.json --- .../accounting_dimension_filter.json | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.json b/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.json index 2bd6c12a0a3..bee30296eed 100644 --- a/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.json +++ b/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.json @@ -7,6 +7,7 @@ "engine": "InnoDB", "field_order": [ "accounting_dimension", + "fieldname", "disabled", "column_break_2", "company", @@ -90,11 +91,21 @@ "fieldname": "apply_restriction_on_values", "fieldtype": "Check", "label": "Apply restriction on dimension values" + }, + { + "fieldname": "fieldname", + "fieldtype": "Data", + "hidden": 1, + "label": "Fieldname" } ], "index_web_pages_for_search": 1, "links": [], +<<<<<<< HEAD "modified": "2023-06-07 14:59:41.869117", +======= + "modified": "2025-08-08 14:13:22.203011", +>>>>>>> ac2acc535d (fix: add fieldname in accounting dimension filter) "modified_by": "Administrator", "module": "Accounts", "name": "Accounting Dimension Filter", @@ -139,8 +150,13 @@ } ], "quick_entry": 1, +<<<<<<< HEAD "sort_field": "modified", +======= + "row_format": "Dynamic", + "sort_field": "creation", +>>>>>>> ac2acc535d (fix: add fieldname in accounting dimension filter) "sort_order": "DESC", "states": [], "track_changes": 1 -} \ No newline at end of file +} From d494d8c29988cd24de87bd248fce642a33215a3e Mon Sep 17 00:00:00 2001 From: l0gesh29 Date: Fri, 8 Aug 2025 14:21:00 +0530 Subject: [PATCH 2/6] fix: fetch fieldname in accounting dimension filter (cherry picked from commit 42f9d27d79735fad57f59c97f93bacadb4424aa3) --- .../accounting_dimension_filter.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.py b/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.py index 7c843cf552e..841eab6bced 100644 --- a/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.py +++ b/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.py @@ -17,17 +17,16 @@ class AccountingDimensionFilter(Document): from frappe.types import DF from erpnext.accounts.doctype.allowed_dimension.allowed_dimension import AllowedDimension - from erpnext.accounts.doctype.applicable_on_account.applicable_on_account import ( - ApplicableOnAccount, - ) + from erpnext.accounts.doctype.applicable_on_account.applicable_on_account import ApplicableOnAccount - accounting_dimension: DF.Literal + accounting_dimension: DF.Literal[None] accounts: DF.Table[ApplicableOnAccount] allow_or_restrict: DF.Literal["Allow", "Restrict"] apply_restriction_on_values: DF.Check company: DF.Link dimensions: DF.Table[AllowedDimension] disabled: DF.Check + fieldname: DF.Data | None # end: auto-generated types def before_save(self): @@ -37,6 +36,9 @@ class AccountingDimensionFilter(Document): self.set("dimensions", []) def validate(self): + self.fieldname = frappe.db.get_value( + "Accounting Dimension", {"document_type": self.accounting_dimension}, "fieldname" + ) self.validate_applicable_accounts() def validate_applicable_accounts(self): @@ -72,7 +74,7 @@ def get_dimension_filter_map(): """ SELECT a.applicable_on_account, d.dimension_value, p.accounting_dimension, - p.allow_or_restrict, a.is_mandatory + p.allow_or_restrict, p.fieldname, a.is_mandatory FROM `tabApplicable On Account` a, `tabAccounting Dimension Filter` p @@ -87,8 +89,6 @@ def get_dimension_filter_map(): dimension_filter_map = {} for f in filters: - f.fieldname = scrub(f.accounting_dimension) - build_map( dimension_filter_map, f.fieldname, From a8530105370a177b87b801bb5bc1e94959df981c Mon Sep 17 00:00:00 2001 From: l0gesh29 Date: Tue, 12 Aug 2025 14:28:18 +0530 Subject: [PATCH 3/6] fix: add patch (cherry picked from commit 3cf765d985532292b11ce03d415bcd17f1dea94b) # Conflicts: # erpnext/patches.txt --- erpnext/patches.txt | 6 +++++ ...ieldname_in_accounting_dimension_filter.py | 23 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 erpnext/patches/v15_0/update_fieldname_in_accounting_dimension_filter.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 1087f64276d..aa753e2ba5b 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -419,4 +419,10 @@ erpnext.patches.v15_0.remove_sales_partner_from_consolidated_sales_invoice erpnext.patches.v15_0.repost_gl_entries_with_no_account_subcontracting #2025-08-04 execute:frappe.db.set_single_value("Accounts Settings", "fetch_valuation_rate_for_internal_transaction", 1) erpnext.patches.v15_0.add_company_payment_gateway_account +<<<<<<< HEAD erpnext.patches.v15_0.update_uae_zero_rated_fetch +======= +erpnext.patches.v16_0.update_serial_no_reference_name +erpnext.patches.v16_0.set_invoice_type_in_pos_settings +erpnext.patches.v15_0.update_fieldname_in_accounting_dimension_filter +>>>>>>> 3cf765d985 (fix: add patch) diff --git a/erpnext/patches/v15_0/update_fieldname_in_accounting_dimension_filter.py b/erpnext/patches/v15_0/update_fieldname_in_accounting_dimension_filter.py new file mode 100644 index 00000000000..50d3fbe6f9c --- /dev/null +++ b/erpnext/patches/v15_0/update_fieldname_in_accounting_dimension_filter.py @@ -0,0 +1,23 @@ +import frappe +from frappe.query_builder import DocType + + +def execute(): + ADF = DocType("Accounting Dimension Filter") + AD = DocType("Accounting Dimension") + + accounting_dimension_filter = ( + frappe.qb.from_(ADF) + .join(AD) + .on(AD.document_type == ADF.accounting_dimension) + .select(ADF.name, AD.fieldname) + ).run(as_dict=True) + + for doc in accounting_dimension_filter: + frappe.db.set_value( + "Accounting Dimension Filter", + doc.name, + "fieldname", + doc.fieldname, + update_modified=False, + ) From e50d6c6b62758941e00fe12f009b666c6deb6020 Mon Sep 17 00:00:00 2001 From: l0gesh29 Date: Tue, 12 Aug 2025 12:00:53 +0530 Subject: [PATCH 4/6] fix: handle default accounting dimension (cherry picked from commit 16e440f9a7b20402c8d6e63dc00ac6150ec69485) --- .../accounting_dimension_filter.py | 3 ++- ...pdate_fieldname_in_accounting_dimension_filter.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.py b/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.py index 841eab6bced..040583a2847 100644 --- a/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.py +++ b/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.py @@ -38,7 +38,8 @@ class AccountingDimensionFilter(Document): def validate(self): self.fieldname = frappe.db.get_value( "Accounting Dimension", {"document_type": self.accounting_dimension}, "fieldname" - ) + ) or frappe.scrub(self.accounting_dimension) # scrub to handle default accounting dimension + self.validate_applicable_accounts() def validate_applicable_accounts(self): diff --git a/erpnext/patches/v15_0/update_fieldname_in_accounting_dimension_filter.py b/erpnext/patches/v15_0/update_fieldname_in_accounting_dimension_filter.py index 50d3fbe6f9c..11d2cc91446 100644 --- a/erpnext/patches/v15_0/update_fieldname_in_accounting_dimension_filter.py +++ b/erpnext/patches/v15_0/update_fieldname_in_accounting_dimension_filter.py @@ -3,6 +3,7 @@ from frappe.query_builder import DocType def execute(): + default_accounting_dimension() ADF = DocType("Accounting Dimension Filter") AD = DocType("Accounting Dimension") @@ -21,3 +22,14 @@ def execute(): doc.fieldname, update_modified=False, ) + + +def default_accounting_dimension(): + for accounting_dimension in ["Cost Center", "Project"]: + frappe.db.set_value( + "Accounting Dimension Filter", + {"accounting_dimension": accounting_dimension}, + "fieldname", + frappe.scrub(accounting_dimension), + update_modified=False, + ) From 0cd45a0022440d404b7a6f9a94de804569782f13 Mon Sep 17 00:00:00 2001 From: l0gesh29 Date: Tue, 12 Aug 2025 14:26:18 +0530 Subject: [PATCH 5/6] fix: handle default dimension for all company (cherry picked from commit 77021fff74a0e67b94289501b9d494bd2b9b3a51) --- ...ieldname_in_accounting_dimension_filter.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/erpnext/patches/v15_0/update_fieldname_in_accounting_dimension_filter.py b/erpnext/patches/v15_0/update_fieldname_in_accounting_dimension_filter.py index 11d2cc91446..25a35bc87fc 100644 --- a/erpnext/patches/v15_0/update_fieldname_in_accounting_dimension_filter.py +++ b/erpnext/patches/v15_0/update_fieldname_in_accounting_dimension_filter.py @@ -11,25 +11,26 @@ def execute(): frappe.qb.from_(ADF) .join(AD) .on(AD.document_type == ADF.accounting_dimension) - .select(ADF.name, AD.fieldname) + .select(ADF.name, AD.fieldname, ADF.accounting_dimension) ).run(as_dict=True) for doc in accounting_dimension_filter: + value = doc.fieldname or frappe.scrub(doc.accounting_dimension) frappe.db.set_value( "Accounting Dimension Filter", doc.name, "fieldname", - doc.fieldname, + value, update_modified=False, ) def default_accounting_dimension(): - for accounting_dimension in ["Cost Center", "Project"]: - frappe.db.set_value( - "Accounting Dimension Filter", - {"accounting_dimension": accounting_dimension}, - "fieldname", - frappe.scrub(accounting_dimension), - update_modified=False, + ADF = DocType("Accounting Dimension Filter") + for dim in ("Cost Center", "Project"): + ( + frappe.qb.update(ADF) + .set(ADF.fieldname, frappe.scrub(dim)) + .where(ADF.accounting_dimension == dim) + .run() ) From 4af814dc3bb31d82f7cbe9f18a122d4be71b8402 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 19 Aug 2025 11:06:23 +0530 Subject: [PATCH 6/6] chore: resolve conflicts --- .../accounting_dimension_filter.json | 9 --------- erpnext/patches.txt | 5 ----- 2 files changed, 14 deletions(-) diff --git a/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.json b/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.json index bee30296eed..260bcd11db5 100644 --- a/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.json +++ b/erpnext/accounts/doctype/accounting_dimension_filter/accounting_dimension_filter.json @@ -101,11 +101,7 @@ ], "index_web_pages_for_search": 1, "links": [], -<<<<<<< HEAD - "modified": "2023-06-07 14:59:41.869117", -======= "modified": "2025-08-08 14:13:22.203011", ->>>>>>> ac2acc535d (fix: add fieldname in accounting dimension filter) "modified_by": "Administrator", "module": "Accounts", "name": "Accounting Dimension Filter", @@ -150,12 +146,7 @@ } ], "quick_entry": 1, -<<<<<<< HEAD - "sort_field": "modified", -======= - "row_format": "Dynamic", "sort_field": "creation", ->>>>>>> ac2acc535d (fix: add fieldname in accounting dimension filter) "sort_order": "DESC", "states": [], "track_changes": 1 diff --git a/erpnext/patches.txt b/erpnext/patches.txt index aa753e2ba5b..ae52e1e3a09 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -419,10 +419,5 @@ erpnext.patches.v15_0.remove_sales_partner_from_consolidated_sales_invoice erpnext.patches.v15_0.repost_gl_entries_with_no_account_subcontracting #2025-08-04 execute:frappe.db.set_single_value("Accounts Settings", "fetch_valuation_rate_for_internal_transaction", 1) erpnext.patches.v15_0.add_company_payment_gateway_account -<<<<<<< HEAD erpnext.patches.v15_0.update_uae_zero_rated_fetch -======= -erpnext.patches.v16_0.update_serial_no_reference_name -erpnext.patches.v16_0.set_invoice_type_in_pos_settings erpnext.patches.v15_0.update_fieldname_in_accounting_dimension_filter ->>>>>>> 3cf765d985 (fix: add patch)