From 4cdcab43ee5e325851b765ed147863b8e075240e Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 3 Jun 2019 09:13:12 +0000 Subject: [PATCH] [FIX] mrp: no qty consumed - Create a MO for '[FURN_8855] Drawer' - Consume 1 unit of '[FURN_2100] Drawer Black', but DO NOT consume anything for '[FURN_5623] Drawer Case Black'. - Complete the MO, then Unlock it - Edit the '[FURN_5623] Drawer Case Black' line It is not possible to add a line. This is expected from 9e77ce2edc7e1cd3ce, but we still want to be able to consume some quantity. Instead of canceling the move lines without any quantity consumed, we set it to done. opw-1986919 closes odoo/odoo#33820 Signed-off-by: Nicolas Martinelli (nim) --- addons/mrp/models/mrp_production.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 32e272d1c4a..3639714366d 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -694,8 +694,10 @@ class MrpProduction(models.Model): raise UserError(_('Work order %s is still running') % wo.name) self._check_lots() self.post_inventory() - moves_to_cancel = (self.move_raw_ids | self.move_finished_ids).filtered(lambda x: x.state not in ('done', 'cancel')) - moves_to_cancel._action_cancel() + # Moves without quantity done are not posted => set them as done instead of canceling. In + # case the user edits the MO later on and sets some consumed quantity on those, we do not + # want the move lines to be canceled. + (self.move_raw_ids | self.move_finished_ids).filtered(lambda x: x.state not in ('done', 'cancel')).write({'state': 'done'}) self.write({'state': 'done', 'date_finished': fields.Datetime.now()}) return self.write({'state': 'done'})