From 38f35acffe74dbf82e01a52f20663efdd9d49b9e Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 16 Feb 2026 23:02:15 +0530 Subject: [PATCH] fix: consider sle for negative stock validation --- .../serial_and_batch_bundle/serial_and_batch_bundle.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py index 2dca7e8c907..66df4d2c2fd 100644 --- a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py +++ b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py @@ -1544,10 +1544,13 @@ class SerialandBatchBundle(Document): def get_available_qty_from_sabb(self): batches = [d.batch_no for d in self.entries if d.batch_no] + sle = frappe.qb.DocType("Stock Ledger Entry") child = frappe.qb.DocType("Serial and Batch Entry") query = ( frappe.qb.from_(child) + .inner_join(sle) + .on(child.parent == sle.serial_and_batch_bundle) .select( child.batch_no, child.qty, @@ -1556,6 +1559,7 @@ class SerialandBatchBundle(Document): ) .where( (child.item_code == self.item_code) + & (sle.is_cancelled == 0) & (child.warehouse == self.warehouse) & (child.is_cancelled == 0) & (child.batch_no.isin(batches))