fix: optimized query (#19026)

Co-authored-by: nabinhait
Co-authored-by: sahil28297 <sahilkhan28297@gmail.com>
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index e5a2102..0825557 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -1173,7 +1173,7 @@
 		frappe.db.sql("""UPDATE `tabPurchase Order Item Supplied` pos
 			SET pos.supplied_qty = (SELECT ifnull(sum(transfer_qty), 0) FROM `tabStock Entry Detail` sed
 			WHERE pos.name = sed.po_detail and sed.docstatus = 1)
-			WHERE pos.docstatus = 1""")
+			WHERE pos.docstatus = 1 and pos.parent = %s""", self.purchase_order)
 
 		#Update reserved sub contracted quantity in bin based on Supplied Item Details and
 		for d in self.get("items"):