From cb4afb263b50b2e7c6ecfc2a57bb3df0dfd0f881 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 25 Jun 2019 09:23:32 +0000 Subject: [PATCH] [FIX] mrp: Manufacturing cost analysis report Steps to reproduce the bug: - Create a finished product P with a manufacturing BOM B - Set two components on B C1 and C2 - Create a MO with P and process it(plan and produce it) - Unlock the MO and set the consumed qty of C1 to 0 - Lock and click on Mark as Done - Click on Cost Analysis Bug: C1 was displayed in the report with a qty = 1.0 opw:2010912 closes odoo/odoo#34351 Signed-off-by: Simon Goffin (sig) --- addons/mrp/models/mrp_production.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 3639714366d..7814c1d9133 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -6,7 +6,7 @@ from collections import defaultdict from odoo import api, fields, models, _ from odoo.addons import decimal_precision as dp from odoo.exceptions import AccessError, UserError -from odoo.tools import float_compare, float_round +from odoo.tools import float_compare, float_round, float_is_zero class MrpProduction(models.Model): """ Manufacturing Orders """ @@ -667,6 +667,8 @@ class MrpProduction(models.Model): moves_to_do = order.move_raw_ids.filtered(lambda x: x.state not in ('done', 'cancel')) for move in moves_to_do.filtered(lambda m: m.product_qty == 0.0 and m.quantity_done > 0): move.product_uom_qty = move.quantity_done + for move in moves_to_do.filtered(lambda m: float_is_zero(m.quantity_done, precision_rounding=m.product_uom.rounding)): + move._action_cancel() moves_to_do._action_done() moves_to_do = order.move_raw_ids.filtered(lambda x: x.state == 'done') - moves_not_to_do order._cal_price(moves_to_do)