fix: modify all remaining SRE queries to consider new Closed status

This commit is contained in:
Mihir Kandoi
2025-08-11 10:21:16 +05:30
parent fe4f7b9c2f
commit dbaa44688e
2 changed files with 15 additions and 12 deletions

View File

@@ -855,18 +855,21 @@ class SellingController(StockController):
if not item.get(so_field) or not item.so_detail:
continue
sre_list = frappe.db.get_all(
"Stock Reservation Entry",
{
"docstatus": 1,
"voucher_type": "Sales Order",
"voucher_no": item.get(so_field),
"voucher_detail_no": item.so_detail,
"warehouse": item.warehouse,
"status": ["not in", ["Delivered", "Cancelled"]],
},
order_by="creation",
table = frappe.qb.DocType("Stock Reservation Entry")
query = (
frappe.qb.from_(table)
.select(table.name)
.where(
(table.docstatus == 1)
& (table.voucher_type == "Sales Order")
& (table.voucher_no == item.get(so_field))
& (table.voucher_detail_no == item.so_detail)
& (table.warehouse == item.warehouse)
& (table.delivered_qty < table.reserved_qty)
)
.orderby(table.creation)
)
sre_list = query.run(pluck="name")
# Skip if no Stock Reservation Entries.
if not sre_list:

View File

@@ -1425,7 +1425,7 @@ class StockReservation:
)
.where(
(sre.docstatus == 1)
& (sre.status.notin(["Delivered", "Cancelled", "Draft", "Closed"]))
& (sre.delivered_qty < sre.reserved_qty)
& (sre.voucher_type == doctype)
& (sre.voucher_no.isin(docnames))
)