diff --git a/addons/mrp/i18n/mrp.pot b/addons/mrp/i18n/mrp.pot index c85998a4bc1..5e0eaf9128d 100644 --- a/addons/mrp/i18n/mrp.pot +++ b/addons/mrp/i18n/mrp.pot @@ -3244,7 +3244,13 @@ msgid "You can not delete a Bill of Material with running manufacturing orders.\ msgstr "" #. module: mrp -#: code:addons/mrp/models/stock_move.py:123 +#: code:addons/mrp/models/stock_move.py:40 +#, python-format +msgid "You can only produce 1.0 %s for products with unique serial number." +msgstr "" + +#. module: mrp +#: code:addons/mrp/models/stock_move.py:135 #, python-format msgid "You cannot cancel a move move having already consumed material" msgstr "" diff --git a/addons/mrp/models/stock_move.py b/addons/mrp/models/stock_move.py index 608d11e9bce..5cb92a5025c 100644 --- a/addons/mrp/models/stock_move.py +++ b/addons/mrp/models/stock_move.py @@ -29,13 +29,15 @@ class StockMoveLots(models.Model): plus_visible = fields.Boolean("Plus Visible", compute='_compute_plus') @api.one - @api.constrains('lot_id') + @api.constrains('lot_id', 'quantity_done') def _check_lot_id(self): if self.move_id.product_id.tracking == 'serial': lots = set([]) for move_lot in self.move_id.move_lot_ids.filtered(lambda r: not r.lot_produced_id): if move_lot.lot_id in lots: raise exceptions.UserError(_('You cannot use the same serial number in two different lines.')) + if float_compare(move_lot.quantity_done, 1.0, precision_rounding=move_lot.product_id.uom_id.rounding) == 1: + raise exceptions.UserError(_('You can only produce 1.0 %s for products with unique serial number.') % move_lot.product_id.uom_id.name) lots.add(move_lot.lot_id) def _compute_plus(self):