From 7ccb2584c480747c2062896a245502f5a3d3832c Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Wed, 15 Jul 2026 12:19:21 +0530 Subject: [PATCH] test: set delivered batch on the row explicitly on v16 The v16 reserved-stock mapper attaches neither a bundle nor row serial/batch fields when use_serial_batch_fields is enabled, and update_stock_reservation_entries crashes on the missing bundle (fixed on develop by 9c5f9218b5, not backported). Deliver via an explicit row batch_no like the guard test so the bundle is built from row fields before the reservation update runs. --- .../test_stock_reservation_entry.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/erpnext/stock/doctype/stock_reservation_entry/test_stock_reservation_entry.py b/erpnext/stock/doctype/stock_reservation_entry/test_stock_reservation_entry.py index 008e9305775..c17e5131669 100644 --- a/erpnext/stock/doctype/stock_reservation_entry/test_stock_reservation_entry.py +++ b/erpnext/stock/doctype/stock_reservation_entry/test_stock_reservation_entry.py @@ -704,11 +704,14 @@ class TestStockReservationEntry(ERPNextTestSuite): "enable_stock_reservation": 1, "auto_reserve_serial_and_batch": 1, "pick_serial_and_batch_based_on": "FIFO", + "use_serial_batch_fields": 1, }, ) def test_batch_shared_across_sales_orders_can_be_delivered(self) -> None: # Regression (#57159): one batch reserved by two Sales Orders. Delivering each order's own # reserved unit must not raise Reserved Batch Conflict — the remainder covers the other order. + # The batch is set on the row explicitly as the v16 reserved-stock mapper does not carry + # the reserved batch onto the Delivery Note row. item_doc = make_batch_item() create_material_receipt(items={item_doc.name: item_doc}, warehouse=self.warehouse, qty=2) @@ -718,12 +721,11 @@ class TestStockReservationEntry(ERPNextTestSuite): so.create_stock_reservation_entries() orders.append(so) - self.assertEqual( - len(get_reserved_batch_nos(orders[0].name) | get_reserved_batch_nos(orders[1].name)), 1 - ) + (batch_no,) = get_reserved_batch_nos(orders[0].name) | get_reserved_batch_nos(orders[1].name) for so in orders: - dn = make_delivery_note(so.name, kwargs={"for_reserved_stock": 1}) + dn = make_delivery_note(so.name) + dn.items[0].batch_no = batch_no dn.save() dn.submit() self.assertEqual(dn.docstatus, 1)