mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-22 22:49:19 +00:00
fix: compare against stock qty while validating
Other changes: - only allow whole number of bundles to get picked
This commit is contained in:
@@ -803,7 +803,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "picked_qty",
|
"fieldname": "picked_qty",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"label": "Picked Qty",
|
"label": "Picked Qty (in Stock UOM)",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
}
|
}
|
||||||
@@ -811,7 +811,7 @@
|
|||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-04-21 08:15:14.010319",
|
"modified": "2022-04-27 03:15:34.366563",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Selling",
|
"module": "Selling",
|
||||||
"name": "Sales Order Item",
|
"name": "Sales Order Item",
|
||||||
|
|||||||
@@ -85,9 +85,12 @@ class PickList(Document):
|
|||||||
|
|
||||||
def update_sales_order_item(self, item, picked_qty, item_code):
|
def update_sales_order_item(self, item, picked_qty, item_code):
|
||||||
item_table = "Sales Order Item" if not item.product_bundle_item else "Packed Item"
|
item_table = "Sales Order Item" if not item.product_bundle_item else "Packed Item"
|
||||||
|
stock_qty_field = "stock_qty" if not item.product_bundle_item else "qty"
|
||||||
|
|
||||||
already_picked, actual_qty = frappe.db.get_value(
|
already_picked, actual_qty = frappe.db.get_value(
|
||||||
item_table, item.sales_order_item, ["picked_qty", "qty"]
|
item_table,
|
||||||
|
item.sales_order_item,
|
||||||
|
["picked_qty", stock_qty_field],
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.docstatus == 1:
|
if self.docstatus == 1:
|
||||||
@@ -259,7 +262,7 @@ class PickList(Document):
|
|||||||
product_bundle_qty_map[bundle_item_code] = {item.item_code: item.qty for item in bundle.items}
|
product_bundle_qty_map[bundle_item_code] = {item.item_code: item.qty for item in bundle.items}
|
||||||
return product_bundle_qty_map
|
return product_bundle_qty_map
|
||||||
|
|
||||||
def _compute_picked_qty_for_bundle(self, bundle_row, bundle_items) -> float:
|
def _compute_picked_qty_for_bundle(self, bundle_row, bundle_items) -> int:
|
||||||
"""Compute how many full bundles can be created from picked items."""
|
"""Compute how many full bundles can be created from picked items."""
|
||||||
precision = frappe.get_precision("Stock Ledger Entry", "qty_after_transaction")
|
precision = frappe.get_precision("Stock Ledger Entry", "qty_after_transaction")
|
||||||
|
|
||||||
@@ -272,7 +275,7 @@ class PickList(Document):
|
|||||||
possible_bundles.append(item.picked_qty / qty_in_bundle)
|
possible_bundles.append(item.picked_qty / qty_in_bundle)
|
||||||
else:
|
else:
|
||||||
possible_bundles.append(0)
|
possible_bundles.append(0)
|
||||||
return flt(min(possible_bundles), precision or 6)
|
return int(flt(min(possible_bundles), precision or 6))
|
||||||
|
|
||||||
|
|
||||||
def validate_item_locations(pick_list):
|
def validate_item_locations(pick_list):
|
||||||
|
|||||||
@@ -582,8 +582,23 @@ class TestPickList(FrappeTestCase):
|
|||||||
if dn_item.item_code == "_Test Item 2":
|
if dn_item.item_code == "_Test Item 2":
|
||||||
self.assertEqual(dn_item.qty, 2)
|
self.assertEqual(dn_item.qty, 2)
|
||||||
|
|
||||||
|
def test_picklist_with_multi_uom(self):
|
||||||
|
warehouse = "_Test Warehouse - _TC"
|
||||||
|
item = make_item(properties={"uoms": [dict(uom="Box", conversion_factor=24)]}).name
|
||||||
|
make_stock_entry(item=item, to_warehouse=warehouse, qty=1000)
|
||||||
|
|
||||||
|
so = make_sales_order(item_code=item, qty=10, rate=42, uom="Box")
|
||||||
|
pl = create_pick_list(so.name)
|
||||||
|
# pick half the qty
|
||||||
|
for loc in pl.locations:
|
||||||
|
loc.picked_qty = loc.stock_qty / 2
|
||||||
|
pl.save()
|
||||||
|
pl.submit()
|
||||||
|
|
||||||
|
so.reload()
|
||||||
|
self.assertEqual(so.per_picked, 50)
|
||||||
|
|
||||||
def test_picklist_with_bundles(self):
|
def test_picklist_with_bundles(self):
|
||||||
# from test_records.json
|
|
||||||
warehouse = "_Test Warehouse - _TC"
|
warehouse = "_Test Warehouse - _TC"
|
||||||
|
|
||||||
quantities = [5, 2]
|
quantities = [5, 2]
|
||||||
|
|||||||
Reference in New Issue
Block a user