From 6a1e272ccd804b068ae8fccbf0483a5ebad603d2 Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Wed, 14 Aug 2019 15:24:01 +0000 Subject: [PATCH] [FIX] stock: do not raise if writing the same value Rewrite the product associated to a serial number. There is a check to forbid this if some move lines already exist. This check does not actually care what value is written, so it can raise uselessly (and forbid a legitimate write). opw 2049717 closes odoo/odoo#35736 Signed-off-by: Nans Lefebvre (len) --- addons/stock/models/stock_production_lot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/models/stock_production_lot.py b/addons/stock/models/stock_production_lot.py index 5a7a72074aa..cbb074cb669 100644 --- a/addons/stock/models/stock_production_lot.py +++ b/addons/stock/models/stock_production_lot.py @@ -40,7 +40,7 @@ class ProductionLot(models.Model): @api.multi def write(self, vals): if 'product_id' in vals: - move_lines = self.env['stock.move.line'].search([('lot_id', 'in', self.ids)]) + move_lines = self.env['stock.move.line'].search([('lot_id', 'in', self.ids), ('product_id', '!=', vals['product_id'])]) if move_lines: raise UserError(_( 'You are not allowed to change the product linked to a serial or lot number ' +