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

View File

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