mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-21 07:38:29 +00:00
fix: consider sle for negative stock validation
This commit is contained in:
@@ -1512,17 +1512,17 @@ class SerialandBatchBundle(Document):
|
|||||||
def get_available_qty_from_sabb(self):
|
def get_available_qty_from_sabb(self):
|
||||||
batches = [d.batch_no for d in self.entries if d.batch_no]
|
batches = [d.batch_no for d in self.entries if d.batch_no]
|
||||||
|
|
||||||
parent = frappe.qb.DocType("Serial and Batch Bundle")
|
parent = frappe.qb.DocType("Stock Ledger Entry")
|
||||||
child = frappe.qb.DocType("Serial and Batch Entry")
|
child = frappe.qb.DocType("Serial and Batch Entry")
|
||||||
|
|
||||||
query = (
|
query = (
|
||||||
frappe.qb.from_(parent)
|
frappe.qb.from_(parent)
|
||||||
.inner_join(child)
|
.inner_join(child)
|
||||||
.on(parent.name == child.parent)
|
.on(parent.serial_and_batch_bundle == child.parent)
|
||||||
.select(
|
.select(
|
||||||
child.batch_no,
|
child.batch_no,
|
||||||
child.qty,
|
child.qty,
|
||||||
CombineDatetime(parent.posting_date, parent.posting_time).as_("posting_datetime"),
|
parent.posting_datetime,
|
||||||
parent.creation,
|
parent.creation,
|
||||||
)
|
)
|
||||||
.where(
|
.where(
|
||||||
@@ -1531,13 +1531,10 @@ class SerialandBatchBundle(Document):
|
|||||||
& (child.batch_no.isin(batches))
|
& (child.batch_no.isin(batches))
|
||||||
& (parent.docstatus == 1)
|
& (parent.docstatus == 1)
|
||||||
& (parent.is_cancelled == 0)
|
& (parent.is_cancelled == 0)
|
||||||
& (parent.type_of_transaction.isin(["Inward", "Outward"]))
|
|
||||||
)
|
)
|
||||||
.for_update()
|
.for_update()
|
||||||
)
|
)
|
||||||
|
|
||||||
query = query.where(parent.voucher_type != "Pick List")
|
|
||||||
|
|
||||||
return query.run(as_dict=True)
|
return query.run(as_dict=True)
|
||||||
|
|
||||||
def validate_voucher_no_docstatus(self):
|
def validate_voucher_no_docstatus(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user