[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) <len@odoo.com>
This commit is contained in:
@@ -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 ' +
|
||||
|
||||
Reference in New Issue
Block a user