[FIX] mrp: wrong consumption warning lines
To reproduce: 1. Create an MO of Product with BOM 2. Manually set qty for a component 3. Produce all Issue: Two consumtion warning lines are shown, and numbers are wrong Part-of: odoo/odoo#140753
This commit is contained in:
@@ -1518,11 +1518,13 @@ class MrpProduction(models.Model):
|
||||
for move in order.move_raw_ids:
|
||||
quantity = move.product_uom._compute_quantity(move.quantity, move.product_id.uom_id)
|
||||
rounding = move.product_id.uom_id.rounding
|
||||
if not (move.product_id in expected_qty_by_product or float_is_zero(quantity, precision_rounding=rounding)) or not move.picked:
|
||||
issues.append((order, move.product_id, quantity, 0.0))
|
||||
# extra lines with non-zero qty picked
|
||||
if move.product_id not in expected_qty_by_product and move.picked and not float_is_zero(quantity, precision_rounding=rounding):
|
||||
issues.append((order, move.product_id, 0.0, quantity))
|
||||
continue
|
||||
done_qty_by_product[move.product_id] += quantity
|
||||
done_qty_by_product[move.product_id] += quantity if move.picked else 0.0
|
||||
|
||||
# origin lines from bom with different qty
|
||||
for product, qty_to_consume in expected_qty_by_product.items():
|
||||
quantity = done_qty_by_product.get(product, 0.0)
|
||||
if float_compare(qty_to_consume, quantity, precision_rounding=product.uom_id.rounding) != 0:
|
||||
|
||||
@@ -3566,9 +3566,9 @@ class TestMrpOrder(TestMrpCommon):
|
||||
action = mo.button_mark_done()
|
||||
consumption_warning = Form(self.env['mrp.consumption.warning'].with_context(**action['context'])).save()
|
||||
|
||||
self.assertEqual(len(consumption_warning.mrp_consumption_warning_line_ids), 2)
|
||||
self.assertEqual(len(consumption_warning.mrp_consumption_warning_line_ids), 1)
|
||||
self.assertEqual(consumption_warning.mrp_consumption_warning_line_ids[0].product_consumed_qty_uom, 0)
|
||||
self.assertEqual(consumption_warning.mrp_consumption_warning_line_ids[0].product_expected_qty_uom, 0)
|
||||
self.assertEqual(consumption_warning.mrp_consumption_warning_line_ids[0].product_expected_qty_uom, 1)
|
||||
# Force the warning
|
||||
consumption_warning.action_confirm()
|
||||
self.assertEqual(mo.state, 'done')
|
||||
|
||||
Reference in New Issue
Block a user