mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-23 16:48:30 +00:00
Merge pull request #50668 from frappe/mergify/bp/version-15/pr-50612
fix: ignore reserved batches from total available batches (backport #50612)
This commit is contained in:
@@ -2297,7 +2297,11 @@ def get_auto_batch_nos(kwargs):
|
|||||||
|
|
||||||
stock_ledgers_batches = get_stock_ledgers_batches(kwargs)
|
stock_ledgers_batches = get_stock_ledgers_batches(kwargs)
|
||||||
pos_invoice_batches = get_reserved_batches_for_pos(kwargs)
|
pos_invoice_batches = get_reserved_batches_for_pos(kwargs)
|
||||||
sre_reserved_batches = get_reserved_batches_for_sre(kwargs)
|
|
||||||
|
sre_reserved_batches = frappe._dict()
|
||||||
|
if not kwargs.ignore_reserved_stock:
|
||||||
|
sre_reserved_batches = get_reserved_batches_for_sre(kwargs)
|
||||||
|
|
||||||
picked_batches = frappe._dict()
|
picked_batches = frappe._dict()
|
||||||
if kwargs.get("is_pick_list"):
|
if kwargs.get("is_pick_list"):
|
||||||
picked_batches = get_picked_batches(kwargs)
|
picked_batches = get_picked_batches(kwargs)
|
||||||
|
|||||||
@@ -678,6 +678,36 @@ class TestStockReservationEntry(FrappeTestCase):
|
|||||||
# Test - 1: ValidationError should be thrown as the inwarded stock is reserved.
|
# Test - 1: ValidationError should be thrown as the inwarded stock is reserved.
|
||||||
self.assertRaises(frappe.ValidationError, se.cancel)
|
self.assertRaises(frappe.ValidationError, se.cancel)
|
||||||
|
|
||||||
|
@change_settings("Stock Settings", {"allow_negative_stock": 0, "enable_stock_reservation": 1})
|
||||||
|
def test_reserved_stock_validation_for_batch_item(self):
|
||||||
|
item_properties = {
|
||||||
|
"is_stock_item": 1,
|
||||||
|
"valuation_rate": 100,
|
||||||
|
"has_batch_no": 1,
|
||||||
|
"create_new_batch": 1,
|
||||||
|
"batch_number_series": "SRBV-.#####.",
|
||||||
|
}
|
||||||
|
sr_item = make_item(item_code="Test Reserve Item", properties=item_properties)
|
||||||
|
# inward 100 qty of stock
|
||||||
|
create_material_receipt(items={sr_item.name: sr_item}, warehouse=self.warehouse, qty=100)
|
||||||
|
|
||||||
|
# reserve 80 qty from sales order
|
||||||
|
so = make_sales_order(item_code=sr_item.name, warehouse=self.warehouse, qty=80)
|
||||||
|
so.create_stock_reservation_entries()
|
||||||
|
|
||||||
|
# create a material issue entry including the reserved qty 10
|
||||||
|
se = make_stock_entry(
|
||||||
|
item_code=sr_item.name,
|
||||||
|
qty=30,
|
||||||
|
from_warehouse=self.warehouse,
|
||||||
|
rate=100,
|
||||||
|
purpose="Material Issue",
|
||||||
|
do_not_submit=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# validation for reserved stock should be thrown
|
||||||
|
self.assertRaises(frappe.ValidationError, se.submit)
|
||||||
|
|
||||||
def tearDown(self) -> None:
|
def tearDown(self) -> None:
|
||||||
cancel_all_stock_reservation_entries()
|
cancel_all_stock_reservation_entries()
|
||||||
return super().tearDown()
|
return super().tearDown()
|
||||||
|
|||||||
@@ -2313,6 +2313,7 @@ def validate_reserved_batch_nos(kwargs):
|
|||||||
"posting_date": kwargs.posting_date,
|
"posting_date": kwargs.posting_date,
|
||||||
"posting_time": kwargs.posting_time,
|
"posting_time": kwargs.posting_time,
|
||||||
"ignore_voucher_nos": kwargs.ignore_voucher_nos,
|
"ignore_voucher_nos": kwargs.ignore_voucher_nos,
|
||||||
|
"ignore_reserved_stock": True,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user