diff --git a/addons/mrp/wizard/change_production_qty.py b/addons/mrp/wizard/change_production_qty.py index b408bef5f8b..cd3cf5a5864 100644 --- a/addons/mrp/wizard/change_production_qty.py +++ b/addons/mrp/wizard/change_production_qty.py @@ -55,7 +55,6 @@ class ChangeProductionQty(models.TransientModel): operation_bom_qty[operation.id] = bom_data['qty'] self._update_product_to_produce(production, production.product_qty - qty_produced) moves = production.move_raw_ids.filtered(lambda x: x.state not in ('done', 'cancel')) - moves.do_unreserve() moves.action_assign() for wo in production.workorder_ids: operation = wo.operation_id diff --git a/addons/mrp/wizard/mrp_product_produce.py b/addons/mrp/wizard/mrp_product_produce.py index b887ac2a62d..8b08771e6e6 100644 --- a/addons/mrp/wizard/mrp_product_produce.py +++ b/addons/mrp/wizard/mrp_product_produce.py @@ -78,22 +78,22 @@ class MrpProductProduce(models.TransientModel): @api.multi def do_produce(self): # Nothing to do for lots since values are created using default data (stock.move.lots) - moves = self.production_id.move_raw_ids quantity = self.product_qty if float_compare(quantity, 0, precision_rounding=self.product_uom_id.rounding) <= 0: raise UserError(_('You should at least produce some quantity')) - for move in moves.filtered(lambda x: x.product_id.tracking == 'none' and x.quantity_done == 0 and x.state not in ('done', 'cancel')): - if move.unit_factor: + for move in self.production_id.move_raw_ids: + # TODO currently not possible to guess if the user updated quantity by hand or automatically by the produce wizard. + if move.product_id.tracking == 'none' and move.quantity_done < move.product_uom_qty and move.state not in ('done', 'cancel') and move.unit_factor: rounding = move.product_uom.rounding move.quantity_done += float_round(quantity * move.unit_factor, precision_rounding=rounding) - moves = self.production_id.move_finished_ids.filtered(lambda x: x.product_id.tracking == 'none' and x.state not in ('done', 'cancel')) - for move in moves: - rounding = move.product_uom.rounding - if move.product_id.id == self.production_id.product_id.id: - move.quantity_done += float_round(quantity, precision_rounding=rounding) - elif move.unit_factor: - # byproducts handling - move.quantity_done += float_round(quantity * move.unit_factor, precision_rounding=rounding) + for move in self.production_id.move_finished_ids: + if move.product_id.tracking == 'none' and move.state not in ('done', 'cancel'): + rounding = move.product_uom.rounding + if move.product_id.id == self.production_id.product_id.id: + move.quantity_done += float_round(quantity, precision_rounding=rounding) + elif move.unit_factor: + # byproducts handling + move.quantity_done += float_round(quantity * move.unit_factor, precision_rounding=rounding) self.check_finished_move_lots() if self.production_id.state == 'confirmed': self.production_id.write({