[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 9e77ce2edc, 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) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2019-06-03 11:45:00 +00:00
parent 9b26052c54
commit 4cdcab43ee
+4 -2
View File
@@ -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'})