From 4dc2969fa6178eaaea56a9d11c759089ac55c099 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 4 Jun 2025 16:57:36 +0530 Subject: [PATCH] perf: avoid duplicate fetching of stock qty --- erpnext/controllers/selling_controller.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index dff14d91daa..9a70f6c3636 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -21,7 +21,11 @@ class SellingController(StockController): def onload(self): super().onload() - if self.doctype in ("Sales Order", "Delivery Note", "Sales Invoice", "Quotation"): + if ( + self.doctype in ("Sales Order", "Delivery Note", "Sales Invoice", "Quotation") + and self.docstatus.is_draft() + and not hasattr(self, "_action") + ): for item in self.get("items") + (self.get("packed_items") or []): company = self.company