mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-18 20:49:19 +00:00
Merge pull request #49218 from frappe/mergify/bp/version-15-hotfix/pr-49055
fix: fetch fieldname in accounting dimension filter (backport #49055)
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"accounting_dimension",
|
"accounting_dimension",
|
||||||
|
"fieldname",
|
||||||
"disabled",
|
"disabled",
|
||||||
"column_break_2",
|
"column_break_2",
|
||||||
"company",
|
"company",
|
||||||
@@ -90,11 +91,17 @@
|
|||||||
"fieldname": "apply_restriction_on_values",
|
"fieldname": "apply_restriction_on_values",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Apply restriction on dimension values"
|
"label": "Apply restriction on dimension values"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "fieldname",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Fieldname"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-06-07 14:59:41.869117",
|
"modified": "2025-08-08 14:13:22.203011",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Accounting Dimension Filter",
|
"name": "Accounting Dimension Filter",
|
||||||
@@ -139,7 +146,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"quick_entry": 1,
|
"quick_entry": 1,
|
||||||
"sort_field": "modified",
|
"sort_field": "creation",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"states": [],
|
"states": [],
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
|
|||||||
@@ -17,17 +17,16 @@ class AccountingDimensionFilter(Document):
|
|||||||
from frappe.types import DF
|
from frappe.types import DF
|
||||||
|
|
||||||
from erpnext.accounts.doctype.allowed_dimension.allowed_dimension import AllowedDimension
|
from erpnext.accounts.doctype.allowed_dimension.allowed_dimension import AllowedDimension
|
||||||
from erpnext.accounts.doctype.applicable_on_account.applicable_on_account import (
|
from erpnext.accounts.doctype.applicable_on_account.applicable_on_account import ApplicableOnAccount
|
||||||
ApplicableOnAccount,
|
|
||||||
)
|
|
||||||
|
|
||||||
accounting_dimension: DF.Literal
|
accounting_dimension: DF.Literal[None]
|
||||||
accounts: DF.Table[ApplicableOnAccount]
|
accounts: DF.Table[ApplicableOnAccount]
|
||||||
allow_or_restrict: DF.Literal["Allow", "Restrict"]
|
allow_or_restrict: DF.Literal["Allow", "Restrict"]
|
||||||
apply_restriction_on_values: DF.Check
|
apply_restriction_on_values: DF.Check
|
||||||
company: DF.Link
|
company: DF.Link
|
||||||
dimensions: DF.Table[AllowedDimension]
|
dimensions: DF.Table[AllowedDimension]
|
||||||
disabled: DF.Check
|
disabled: DF.Check
|
||||||
|
fieldname: DF.Data | None
|
||||||
# end: auto-generated types
|
# end: auto-generated types
|
||||||
|
|
||||||
def before_save(self):
|
def before_save(self):
|
||||||
@@ -37,6 +36,10 @@ class AccountingDimensionFilter(Document):
|
|||||||
self.set("dimensions", [])
|
self.set("dimensions", [])
|
||||||
|
|
||||||
def validate(self):
|
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()
|
self.validate_applicable_accounts()
|
||||||
|
|
||||||
def validate_applicable_accounts(self):
|
def validate_applicable_accounts(self):
|
||||||
@@ -72,7 +75,7 @@ def get_dimension_filter_map():
|
|||||||
"""
|
"""
|
||||||
SELECT
|
SELECT
|
||||||
a.applicable_on_account, d.dimension_value, p.accounting_dimension,
|
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
|
FROM
|
||||||
`tabApplicable On Account` a,
|
`tabApplicable On Account` a,
|
||||||
`tabAccounting Dimension Filter` p
|
`tabAccounting Dimension Filter` p
|
||||||
@@ -87,8 +90,6 @@ def get_dimension_filter_map():
|
|||||||
dimension_filter_map = {}
|
dimension_filter_map = {}
|
||||||
|
|
||||||
for f in filters:
|
for f in filters:
|
||||||
f.fieldname = scrub(f.accounting_dimension)
|
|
||||||
|
|
||||||
build_map(
|
build_map(
|
||||||
dimension_filter_map,
|
dimension_filter_map,
|
||||||
f.fieldname,
|
f.fieldname,
|
||||||
|
|||||||
@@ -420,3 +420,4 @@ erpnext.patches.v15_0.repost_gl_entries_with_no_account_subcontracting #2025-08-
|
|||||||
execute:frappe.db.set_single_value("Accounts Settings", "fetch_valuation_rate_for_internal_transaction", 1)
|
execute:frappe.db.set_single_value("Accounts Settings", "fetch_valuation_rate_for_internal_transaction", 1)
|
||||||
erpnext.patches.v15_0.add_company_payment_gateway_account
|
erpnext.patches.v15_0.add_company_payment_gateway_account
|
||||||
erpnext.patches.v15_0.update_uae_zero_rated_fetch
|
erpnext.patches.v15_0.update_uae_zero_rated_fetch
|
||||||
|
erpnext.patches.v15_0.update_fieldname_in_accounting_dimension_filter
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import frappe
|
||||||
|
from frappe.query_builder import DocType
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
default_accounting_dimension()
|
||||||
|
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, 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",
|
||||||
|
value,
|
||||||
|
update_modified=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def default_accounting_dimension():
|
||||||
|
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()
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user