Skip to content

Commit ca8f324

Browse files
rohitwaghchauremergify[bot]
authored andcommitted
fix: consider sle for negative stock validation
(cherry picked from commit 38f35ac)
1 parent d2eabcb commit ca8f324

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,10 +1545,13 @@ def get_available_qty_from_stock_ledger(self):
15451545
def get_available_qty_from_sabb(self):
15461546
batches = [d.batch_no for d in self.entries if d.batch_no]
15471547

1548+
sle = frappe.qb.DocType("Stock Ledger Entry")
15481549
child = frappe.qb.DocType("Serial and Batch Entry")
15491550

15501551
query = (
15511552
frappe.qb.from_(child)
1553+
.inner_join(sle)
1554+
.on(child.parent == sle.serial_and_batch_bundle)
15521555
.select(
15531556
child.batch_no,
15541557
child.qty,
@@ -1557,6 +1560,7 @@ def get_available_qty_from_sabb(self):
15571560
)
15581561
.where(
15591562
(child.item_code == self.item_code)
1563+
& (sle.is_cancelled == 0)
15601564
& (child.warehouse == self.warehouse)
15611565
& (child.is_cancelled == 0)
15621566
& (child.batch_no.isin(batches))

0 commit comments

Comments
 (0)