diff --git a/addons/mrp/i18n/mrp.pot b/addons/mrp/i18n/mrp.pot index 7e3938949f6..b4c83f5050c 100644 --- a/addons/mrp/i18n/mrp.pot +++ b/addons/mrp/i18n/mrp.pot @@ -4600,6 +4600,15 @@ msgstr "" msgid "The record id this is attached to." msgstr "" +#. module: mrp +#: code:addons/mrp/models/mrp_unbuild.py:0 +#: code:addons/mrp/models/mrp_unbuild.py:0 +#, python-format +msgid "" +"The selected serial number does not correspond to the one used in the " +"manufacturing order, please select another one." +msgstr "" + #. module: mrp #: code:addons/mrp/models/mrp_production.py:0 #, python-format diff --git a/addons/mrp/models/mrp_unbuild.py b/addons/mrp/models/mrp_unbuild.py index 3defbd6c515..03158172d8c 100644 --- a/addons/mrp/models/mrp_unbuild.py +++ b/addons/mrp/models/mrp_unbuild.py @@ -106,6 +106,19 @@ class MrpUnbuild(models.Model): self.product_qty = 1 else: self.product_qty = self.mo_id.product_qty + if self.lot_id and self.lot_id not in self.mo_id.move_finished_ids.move_line_ids.lot_id: + return {'warning': { + 'title': _("Warning"), + 'message': _("The selected serial number does not correspond to the one used in the manufacturing order, please select another one.") + }} + + @api.onchange('lot_id') + def _onchange_lot_id(self): + if self.mo_id and self.lot_id and self.lot_id not in self.mo_id.move_finished_ids.move_line_ids.lot_id: + return {'warning': { + 'title': _("Warning"), + 'message': _("The selected serial number does not correspond to the one used in the manufacturing order, please select another one.") + }} @api.onchange('product_id') def _onchange_product_id(self):