From 705b9e0181bd30239dd072f8e29fb96009096cfb Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Mon, 2 Jun 2025 11:06:17 +0530 Subject: [PATCH] perf: cache child warehouses during a single request (#47837) Gets called for each row right now, warehouses often same on all items in a document. --- erpnext/stock/doctype/warehouse/warehouse.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py index 28c37c39676..7a472b1b816 100644 --- a/erpnext/stock/doctype/warehouse/warehouse.py +++ b/erpnext/stock/doctype/warehouse/warehouse.py @@ -8,6 +8,7 @@ import frappe from frappe import _, throw from frappe.contacts.address_and_contact import load_address_and_contact from frappe.utils import cint +from frappe.utils.caching import request_cache from frappe.utils.nestedset import NestedSet from pypika.terms import ExistsCriterion @@ -221,6 +222,7 @@ def convert_to_group_or_ledger(docname=None): return frappe.get_doc("Warehouse", docname).convert_to_group_or_ledger() +@request_cache def get_child_warehouses(warehouse): from frappe.utils.nestedset import get_descendants_of