summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2018-04-13 14:19:42 +0200
committerNicolas Martinelli <nim-odoo@users.noreply.github.com>2018-04-16 14:20:44 +0200
commit620a6f45576a9846bbfc756d90a01e7c1d47c8f8 (patch)
tree9733d027194a0a279924952f35612d453dbb8251 /addons
parenta87dc3111c5928d50414b38330a04d2dec0e7f43 (diff)
[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
Diffstat (limited to 'addons')
-rw-r--r--addons/stock/i18n/stock.pot16
-rw-r--r--addons/stock/models/stock_production_lot.py12
2 files changed, 23 insertions, 5 deletions
diff --git a/addons/stock/i18n/stock.pot b/addons/stock/i18n/stock.pot
index 5b13fc1578f..67d78f45413 100644
--- a/addons/stock/i18n/stock.pot
+++ b/addons/stock/i18n/stock.pot
@@ -2289,6 +2289,11 @@ 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)"
msgstr ""
@@ -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
diff --git a/addons/stock/models/stock_production_lot.py b/addons/stock/models/stock_production_lot.py
index 4fc1092839d..5a7a72074aa 100644
--- a/addons/stock/models/stock_production_lot.py
+++ b/addons/stock/models/stock_production_lot.py
@@ -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.