[FIX] mrp: allow selecting only the SNs linked to the MO
Stpes to reproduce the bug:
- Create a storable product “P1”:
- tracking: Serial number
- BOM: 1 unit of C1
- Create the MO 1:
- produce 1 unit of P1:
- Create the SN1
- Create the MO 2:
- produce 1 unit of P1:
- Create the SN2
- Create an Unbuild order:
- Select the MO1
Problem:
You have the possibility to select any Serial number linked
to the product “P1”, whereas only SNs created in this MO can be selected
opw-2834529
closes odoo/odoo#95956
X-original-commit: 167b1668450c5af44bc1d36d1c7d59921bc2b811
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user