diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index a35e16f2c2ff..b463213f50d6 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -1245,14 +1245,18 @@ def create_pick_list(source_name, target_doc=None): from erpnext.stock.doctype.packed_item.packed_item import is_product_bundle def update_item_quantity(source, target, source_parent) -> None: - target.qty = flt(source.qty) - flt(source.delivered_qty) - target.stock_qty = (flt(source.qty) - flt(source.delivered_qty)) * flt(source.conversion_factor) + picked_qty = flt(source.picked_qty) / (flt(source.conversion_factor) or 1) + qty_to_be_picked = flt(source.qty) - max(picked_qty, flt(source.delivered_qty)) + + target.qty = qty_to_be_picked + target.stock_qty = qty_to_be_picked * flt(source.conversion_factor) def update_packed_item_qty(source, target, source_parent) -> None: qty = flt(source.qty) for item in source_parent.items: if source.parent_detail_docname == item.name: - pending_percent = (item.qty - item.delivered_qty) / item.qty + picked_qty = flt(item.picked_qty) / (flt(item.conversion_factor) or 1) + pending_percent = (item.qty - max(picked_qty, item.delivered_qty)) / item.qty target.qty = target.stock_qty = qty * pending_percent return @@ -1281,6 +1285,7 @@ def should_pick_order_item(item) -> bool: "name": "sales_order_item", "parent_detail_docname": "product_bundle_item", }, + "field_no_map": ["picked_qty"], "postprocess": update_packed_item_qty, }, },