mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-13 01:34:10 +00:00
Merge pull request #50993 from frappe/mergify/bp/version-15-hotfix/pr-50910
fix: validate picklist partial reserved qty (backport #50910)
This commit is contained in:
@@ -743,7 +743,10 @@ class PickList(TransactionBase):
|
||||
pi_item.serial_no,
|
||||
(
|
||||
Case()
|
||||
.when((pi_item.picked_qty > 0) & (pi_item.docstatus == 1), pi_item.picked_qty)
|
||||
.when(
|
||||
(pi_item.picked_qty > 0) & (pi_item.docstatus == 1),
|
||||
pi_item.picked_qty - pi_item.delivered_qty,
|
||||
)
|
||||
.else_(pi_item.stock_qty)
|
||||
).as_("picked_qty"),
|
||||
)
|
||||
|
||||
@@ -645,6 +645,46 @@ class TestPickList(FrappeTestCase):
|
||||
if dn_item.item_code == "_Test Item 2":
|
||||
self.assertEqual(dn_item.qty, 2)
|
||||
|
||||
def test_picklist_reserved_qty_validation(self):
|
||||
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
||||
|
||||
warehouse = "_Test Warehouse - _TC"
|
||||
test_stock_item = "_Test Stock Item"
|
||||
|
||||
# Ensure stock item exists
|
||||
if not frappe.db.exists("Item", test_stock_item):
|
||||
create_item(
|
||||
item_code=test_stock_item,
|
||||
is_stock_item=1,
|
||||
)
|
||||
|
||||
# Add initial stock qty
|
||||
make_stock_entry(item_code=test_stock_item, to_warehouse=warehouse, qty=15)
|
||||
|
||||
# Create SO for 10 qty
|
||||
sales_order_1 = make_sales_order(item_code=test_stock_item, warehouse=warehouse, qty=10)
|
||||
|
||||
# Create and Submit picklist for SO
|
||||
picklist_1 = create_pick_list(sales_order_1.name)
|
||||
picklist_1.submit()
|
||||
|
||||
# Create DN for 5 qty
|
||||
dn = create_delivery_note(picklist_1.name)
|
||||
dn.items[0].qty = 5
|
||||
dn.save()
|
||||
dn.submit()
|
||||
|
||||
# Verify partly delivered state
|
||||
picklist_1.reload()
|
||||
self.assertEqual(picklist_1.status, "Partly Delivered")
|
||||
|
||||
# Create another SO (10 qty)
|
||||
sales_order_2 = make_sales_order(item_code=test_stock_item, warehouse=warehouse, qty=10)
|
||||
|
||||
# Expected pick qty = 5
|
||||
picklist_2 = create_pick_list(sales_order_2.name)
|
||||
self.assertEqual(picklist_2.locations[0].qty, 5)
|
||||
|
||||
def test_picklist_with_multi_uom(self):
|
||||
warehouse = "_Test Warehouse - _TC"
|
||||
item = make_item(properties={"uoms": [dict(uom="Box", conversion_factor=24)]}).name
|
||||
|
||||
Reference in New Issue
Block a user