Skip to content
Snippets Groups Projects
Commit 620a6f45 authored by Nicolas Martinelli's avatar Nicolas Martinelli Committed by Nicolas Martinelli
Browse files

[FIX] stock: change product on S/N

Do not allow to change the product on a serial/lot number for a product
which has existing stock moves. Doing so would screw up the traceability
report.

opw-1832452
parent a87dc311
Branches
Tags
No related merge requests found
......@@ -2288,6 +2288,11 @@ msgstr ""
msgid "Has Scrap Moves"
msgstr ""
#. module: stock
#: model:ir.model.fields,field_description:stock.field_stock_picking_has_tracking
msgid "Has Tracking"
msgstr ""
#. module: stock
#: model:ir.model.fields,field_description:stock.field_stock_location_posz
msgid "Height (Z)"
......@@ -4885,6 +4890,7 @@ msgid "Reference of the document"
msgstr ""
#. module: stock
#: model:ir.ui.view,arch_db:stock.view_move_kandan
#: model:ir.ui.view,arch_db:stock.view_picking_form
msgid "Register lots, packs, location"
msgstr ""
......@@ -6643,14 +6649,14 @@ msgid "Whether the move was added after the picking's confirmation"
msgstr ""
#. module: stock
#: model:product.product,name:stock.test_quant_product
#: model:product.template,name:stock.test_quant_product_product_template
msgid "Whiteboard"
#: model:ir.model.fields,field_description:stock.field_stock_return_picking_line_wizard_id
msgid "Wizard"
msgstr ""
#. module: stock
#: model:ir.model.fields,field_description:stock.field_stock_return_picking_line_wizard_id
msgid "Wizard"
#: code:addons/stock/models/stock_production_lot.py:47
#, python-format
msgid "You are not allowed to change the product linked to a serial or lot number if some stock moves have already been created with that number. This would lead to inconsistencies in your stock."
msgstr ""
#. module: stock
......
......@@ -37,6 +37,18 @@ class ProductionLot(models.Model):
raise UserError(_("You are not allowed to create a lot for this picking type"))
return super(ProductionLot, self).create(vals)
@api.multi
def write(self, vals):
if 'product_id' in vals:
move_lines = self.env['stock.move.line'].search([('lot_id', 'in', self.ids)])
if move_lines:
raise UserError(_(
'You are not allowed to change the product linked to a serial or lot number ' +
'if some stock moves have already been created with that number. ' +
'This would lead to inconsistencies in your stock.'
))
return super(ProductionLot, self).write(vals)
@api.one
def _product_qty(self):
# We only care for the quants in internal or transit locations.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment