perf: cache item metadata retrieval (#47929)

* perf(get_item_details): use cached doc, avoid full get_doc

* perf: short-circuit common usecase of same UOM

* perf: use cached doc for inspection

* perf: use cached valuation method and other item props

It rarely if ever changes after initial configuration
This commit is contained in:
Ankush Menat
2025-06-06 17:09:27 +05:30
committed by GitHub
parent 534f90c33d
commit a38ed286bd
5 changed files with 24 additions and 19 deletions

View File

@@ -1053,7 +1053,7 @@ class StockController(AccountsController):
for row in self.get("items"):
qi_required = False
if inspection_required_fieldname and frappe.db.get_value(
if inspection_required_fieldname and frappe.get_cached_value(
"Item", row.item_code, inspection_required_fieldname
):
qi_required = True
@@ -1769,7 +1769,7 @@ def get_conditions_to_validate_future_sle(sl_entries):
for warehouse, items in warehouse_items_map.items():
or_conditions.append(
f"""warehouse = {frappe.db.escape(warehouse)}
and item_code in ({', '.join(frappe.db.escape(item) for item in items)})"""
and item_code in ({", ".join(frappe.db.escape(item) for item in items)})"""
)
return or_conditions