mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-11 22:38:25 +00:00
Merge pull request #52700 from rohitwaghchaure/fixed-negative-stock-validation-sle-v15
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):
|
||||
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")
|
||||
|
||||
query = (
|
||||
frappe.qb.from_(parent)
|
||||
.inner_join(child)
|
||||
.on(parent.name == child.parent)
|
||||
.on(parent.serial_and_batch_bundle == child.parent)
|
||||
.select(
|
||||
child.batch_no,
|
||||
child.qty,
|
||||
CombineDatetime(parent.posting_date, parent.posting_time).as_("posting_datetime"),
|
||||
parent.posting_datetime,
|
||||
parent.creation,
|
||||
)
|
||||
.where(
|
||||
@@ -1531,13 +1531,10 @@ class SerialandBatchBundle(Document):
|
||||
& (child.batch_no.isin(batches))
|
||||
& (parent.docstatus == 1)
|
||||
& (parent.is_cancelled == 0)
|
||||
& (parent.type_of_transaction.isin(["Inward", "Outward"]))
|
||||
)
|
||||
.for_update()
|
||||
)
|
||||
|
||||
query = query.where(parent.voucher_type != "Pick List")
|
||||
|
||||
return query.run(as_dict=True)
|
||||
|
||||
def validate_voucher_no_docstatus(self):
|
||||
|
||||
Reference in New Issue
Block a user