Skip to content

Commit ca79f64

Browse files
fix: consider sle for negative stock validation
1 parent 9ece276 commit ca79f64

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,17 +1512,17 @@ def get_available_qty_from_stock_ledger(self):
15121512
def get_available_qty_from_sabb(self):
15131513
batches = [d.batch_no for d in self.entries if d.batch_no]
15141514

1515-
parent = frappe.qb.DocType("Serial and Batch Bundle")
1515+
parent = frappe.qb.DocType("Stock Ledger Entry")
15161516
child = frappe.qb.DocType("Serial and Batch Entry")
15171517

15181518
query = (
15191519
frappe.qb.from_(parent)
15201520
.inner_join(child)
1521-
.on(parent.name == child.parent)
1521+
.on(parent.serial_and_batch_bundle == child.parent)
15221522
.select(
15231523
child.batch_no,
15241524
child.qty,
1525-
CombineDatetime(parent.posting_date, parent.posting_time).as_("posting_datetime"),
1525+
parent.posting_datetime,
15261526
parent.creation,
15271527
)
15281528
.where(
@@ -1531,13 +1531,10 @@ def get_available_qty_from_sabb(self):
15311531
& (child.batch_no.isin(batches))
15321532
& (parent.docstatus == 1)
15331533
& (parent.is_cancelled == 0)
1534-
& (parent.type_of_transaction.isin(["Inward", "Outward"]))
15351534
)
15361535
.for_update()
15371536
)
15381537

1539-
query = query.where(parent.voucher_type != "Pick List")
1540-
15411538
return query.run(as_dict=True)
15421539

15431540
def validate_voucher_no_docstatus(self):

0 commit comments

Comments
 (0)