fix: handle default dimension for all company

(cherry picked from commit 77021fff74)
This commit is contained in:
l0gesh29
2025-08-12 14:26:18 +05:30
committed by Mergify
parent e50d6c6b62
commit 0cd45a0022

View File

@@ -11,25 +11,26 @@ def execute():
frappe.qb.from_(ADF) frappe.qb.from_(ADF)
.join(AD) .join(AD)
.on(AD.document_type == ADF.accounting_dimension) .on(AD.document_type == ADF.accounting_dimension)
.select(ADF.name, AD.fieldname) .select(ADF.name, AD.fieldname, ADF.accounting_dimension)
).run(as_dict=True) ).run(as_dict=True)
for doc in accounting_dimension_filter: for doc in accounting_dimension_filter:
value = doc.fieldname or frappe.scrub(doc.accounting_dimension)
frappe.db.set_value( frappe.db.set_value(
"Accounting Dimension Filter", "Accounting Dimension Filter",
doc.name, doc.name,
"fieldname", "fieldname",
doc.fieldname, value,
update_modified=False, update_modified=False,
) )
def default_accounting_dimension(): def default_accounting_dimension():
for accounting_dimension in ["Cost Center", "Project"]: ADF = DocType("Accounting Dimension Filter")
frappe.db.set_value( for dim in ("Cost Center", "Project"):
"Accounting Dimension Filter", (
{"accounting_dimension": accounting_dimension}, frappe.qb.update(ADF)
"fieldname", .set(ADF.fieldname, frappe.scrub(dim))
frappe.scrub(accounting_dimension), .where(ADF.accounting_dimension == dim)
update_modified=False, .run()
) )