Merge pull request #57694 from frappe/mergify/bp/version-16-hotfix/pr-57681

fix: set reservation voucher_qty to voucher demand not reserved qty (backport #57681)
This commit is contained in:
Shllokkk
2026-08-01 16:09:20 +05:30
committed by GitHub
2 changed files with 40 additions and 1 deletions

View File

@@ -3823,6 +3823,45 @@ class TestWorkOrder(ERPNextTestSuite):
self.assertRaises(frappe.ValidationError, transfer_entry.submit)
@ERPNextTestSuite.change_settings(
"Stock Settings",
{"enable_stock_reservation": 1, "allow_partial_reservation": 1},
)
def test_partial_reservation_records_full_voucher_qty(self):
# Regression: a short reservation must keep voucher_qty as the full requirement.
from erpnext.stock.doctype.stock_entry.stock_entry_utils import (
make_stock_entry as make_stock_entry_test_record,
)
production_item = "Test Partial Reservation FG"
rm_item = "Test Partial Reservation RM"
source_warehouse = "Stores - _TC"
make_item(production_item, {"is_stock_item": 1})
make_item(rm_item, {"is_stock_item": 1})
make_bom(item=production_item, source_warehouse=source_warehouse, raw_materials=[rm_item])
# Only 6 units on hand while the Work Order needs 10.
make_stock_entry_test_record(item_code=rm_item, target=source_warehouse, qty=6, basic_rate=100)
wo = make_wo_order_test_record(
item=production_item,
qty=10,
reserve_stock=1,
source_warehouse=source_warehouse,
)
sre = frappe.get_all(
"Stock Reservation Entry",
filters={"voucher_no": wo.name, "docstatus": 1},
fields=["voucher_qty", "reserved_qty", "status"],
)
self.assertEqual(len(sre), 1)
self.assertEqual(sre[0].reserved_qty, 6)
self.assertEqual(sre[0].voucher_qty, 10)
self.assertEqual(sre[0].status, "Partially Reserved")
def test_auto_stock_reservation_for_batched_raw_material(self):
from erpnext.stock.doctype.stock_entry.stock_entry_utils import (
make_stock_entry as make_stock_entry_test_record,

View File

@@ -1189,7 +1189,7 @@ class StockReservation:
sre.voucher_no = item.get("voucher_no") or self.doc.name
sre.voucher_detail_no = item.get(child_doctype) or item.name or item.get("voucher_detail_no")
sre.available_qty = self.available_qty_to_reserve
sre.voucher_qty = self.qty_to_be_reserved
sre.voucher_qty = qty
sre.reserved_qty = self.qty_to_be_reserved
sre.company = self.doc.company
sre.stock_uom = item_details.stock_uom