mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-22 14:39:19 +00:00
perf: avoid querying cost center allocation repeatedly
This commit is contained in:
@@ -154,3 +154,7 @@ class CostCenterAllocation(Document):
|
|||||||
).format(d.cost_center),
|
).format(d.cost_center),
|
||||||
InvalidChildCostCenter,
|
InvalidChildCostCenter,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def clear_cache(self):
|
||||||
|
frappe.clear_cache(doctype="Cost Center")
|
||||||
|
return super().clear_cache()
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import frappe
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.meta import get_field_precision
|
from frappe.model.meta import get_field_precision
|
||||||
from frappe.utils import cint, flt, formatdate, get_link_to_form, getdate, now
|
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
|
from frappe.utils.dashboard import cache_source
|
||||||
|
|
||||||
import erpnext
|
import erpnext
|
||||||
@@ -222,6 +223,7 @@ def distribute_gl_based_on_cost_center_allocation(gl_map, precision=None, from_r
|
|||||||
return new_gl_map
|
return new_gl_map
|
||||||
|
|
||||||
|
|
||||||
|
@request_cache
|
||||||
def get_cost_center_allocation_data(company, posting_date, cost_center):
|
def get_cost_center_allocation_data(company, posting_date, cost_center):
|
||||||
cost_center_allocation = frappe.db.get_value(
|
cost_center_allocation = frappe.db.get_value(
|
||||||
"Cost Center Allocation",
|
"Cost Center Allocation",
|
||||||
|
|||||||
Reference in New Issue
Block a user