diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 7e5fc7ec948..ab4e808e06e 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -2497,10 +2497,12 @@ class StockEntry(StockController): wo_item_qty = item.transferred_qty or item.required_qty - wo_qty_consumed = flt(wo_item_qty) - flt(item.consumed_qty) + wo_qty_unconsumed = flt(wo_item_qty) - flt(item.consumed_qty) wo_qty_to_produce = flt(work_order_qty) - flt(wo.produced_qty) + bom_qty_per_unit = item.required_qty / wo.qty # per-unit BOM qty - req_qty_each = (wo_qty_consumed) / (wo_qty_to_produce or 1) + req_qty_each = (wo_qty_unconsumed) / (wo_qty_to_produce or 1) + req_qty_each = min(req_qty_each, bom_qty_per_unit) qty = req_qty_each * flt(self.fg_completed_qty)