perf: batch status check for on-hold/closed documents, remove N+1 queries (#54798)

This commit is contained in:
Shubh Doshi
2026-06-03 11:50:49 +05:30
committed by GitHub
parent 42383c3f36
commit 5074597d00
9 changed files with 62 additions and 66 deletions

View File

@@ -469,11 +469,9 @@ class SellingController(StockController):
return so_qty, so_warehouse
def check_sales_order_on_hold_or_close(self, ref_fieldname):
for d in self.get("items"):
if d.get(ref_fieldname):
status = frappe.db.get_value("Sales Order", d.get(ref_fieldname), "status")
if status in ("Closed", "On Hold") and not self.is_return:
frappe.throw(_("Sales Order {0} is {1}").format(d.get(ref_fieldname), status))
if self.is_return:
return
self.check_for_on_hold_or_closed_status("Sales Order", ref_fieldname)
def update_reserved_qty(self):
so_map = {}