[FIX] mrp: update MO qty with by_product fail

Update MO qty compute the quantity already processed
but it includes the by_product moves.

This commit add a filter in order to only consider the
move with the final product.
This commit is contained in:
amoyaux
2017-10-20 16:06:28 +02:00
parent 1a09bcc622
commit 41d91e2c96
+1 -1
View File
@@ -39,7 +39,7 @@ class ChangeProductionQty(models.TransientModel):
def change_prod_qty(self):
for wizard in self:
production = wizard.mo_id
produced = sum(production.move_finished_ids.mapped('quantity_done'))
produced = sum(production.move_finished_ids.filtered(lambda m: m.product_id == production.product_id).mapped('quantity_done'))
if wizard.product_qty < produced:
raise UserError(_("You have already processed %d. Please input a quantity higher than %d ")%(produced, produced))
production.write({'product_qty': wizard.product_qty})