perf: avoid querying cost center allocation repeatedly

This commit is contained in:
Ankush Menat
2025-06-04 15:55:15 +05:30
parent 013011aa43
commit 9870dd26f7
2 changed files with 6 additions and 0 deletions

View File

@@ -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()

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
from frappe.utils.dashboard import cache_source
import erpnext
@@ -222,6 +223,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",