perf: avoid querying cost center allocation repeatedly

(cherry picked from commit 9870dd26f7)
This commit is contained in:
Ankush Menat
2026-10-24 21:17:43 +05:30
committed by Mihir Kandoi
parent bb9923f6fa
commit ca555b7341
2 changed files with 6 additions and 0 deletions
@@ -154,3 +154,7 @@ class CostCenterAllocation(Document):
).format(d.cost_center),
InvalidChildCostCenter,
)
def clear_cache(self):
frappe.clear_cache(doctype="Cost Center")
return super().clear_cache()
+2
View File
@@ -8,6 +8,7 @@ import frappe
from frappe import _
from frappe.model.meta import get_field_precision
from frappe.utils import cint, flt, formatdate, get_link_to_form, getdate, now
from frappe.utils.caching import request_cache
import erpnext
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
@@ -229,6 +230,7 @@ def distribute_gl_based_on_cost_center_allocation(gl_map, precision=None, from_r
return new_gl_map
@request_cache
def get_cost_center_allocation_data(company, posting_date, cost_center):
cost_center_allocation = frappe.db.get_value(
"Cost Center Allocation",