[FIX] mrp: Unbuild order with serial number
When unbuilding an order with serial number, the quant with the right serial number must be found in the system either it raises an UserError explaining what's the problem. PS: A problem was found when we tried to unbuild two times the same MO. After the first unbuild, we deleted it and recreated the same one. opw:748472
This commit is contained in:
@@ -3266,6 +3266,18 @@ msgstr ""
|
||||
msgid "You cannot use the same serial number in two different lines."
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp
|
||||
#: code:addons/mrp/models/mrp_unbuild.py:110
|
||||
#, python-format
|
||||
msgid "You don't have in the stock the lot %s."
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp
|
||||
#: code:addons/mrp/models/mrp_unbuild.py:125
|
||||
#, python-format
|
||||
msgid "You don't have in the stock the required lot/serial number for %s ."
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp
|
||||
#: code:addons/mrp/wizard/change_production_qty.py:44
|
||||
#, python-format
|
||||
|
||||
@@ -106,6 +106,8 @@ class MrpUnbuild(models.Model):
|
||||
self.env['stock.quant'].quants_reserve(quants, consume_move)
|
||||
|
||||
if consume_move.has_tracking != 'none':
|
||||
if not quants[0][0]:
|
||||
raise UserError(_("You don't have in the stock the lot %s.") % (self.lot_id.name,))
|
||||
self.env['stock.move.lots'].create({
|
||||
'move_id': consume_move.id,
|
||||
'lot_id': self.lot_id.id,
|
||||
@@ -119,6 +121,8 @@ class MrpUnbuild(models.Model):
|
||||
for produce_move in produce_moves:
|
||||
if produce_move.has_tracking != 'none':
|
||||
original = original_quants.filtered(lambda quant: quant.product_id == produce_move.product_id)
|
||||
if not original.lot_id:
|
||||
raise UserError(_("You don't have in the stock the required lot/serial number for %s .") % (produce_move.product_id.name,))
|
||||
self.env['stock.move.lots'].create({
|
||||
'move_id': produce_move.id,
|
||||
'lot_id': original.lot_id.id,
|
||||
|
||||
Reference in New Issue
Block a user