From aba7ffc38d5b49250fa9b41e81ddbc00ffea2ff6 Mon Sep 17 00:00:00 2001 From: Jordi Ballester Date: Mon, 30 May 2022 07:23:17 +0000 Subject: [PATCH] [FIX] product: Only trigger unlink when there are records to unlink MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes odoo/odoo#92663 X-original-commit: 9039380f74984878f95a4dcf9cf425a855330a38 Signed-off-by: Sébastien Theys (seb) --- addons/product/models/product_attribute.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/product/models/product_attribute.py b/addons/product/models/product_attribute.py index 05351f596a5..8bd2957acbb 100644 --- a/addons/product/models/product_attribute.py +++ b/addons/product/models/product_attribute.py @@ -382,7 +382,8 @@ class ProductTemplateAttributeLine(models.Model): # re-use a value that was archived at a previous step. ptav_to_activate.write({'ptav_active': True}) ptav_to_unlink.write({'ptav_active': False}) - ptav_to_unlink.unlink() + if ptav_to_unlink: + ptav_to_unlink.unlink() ProductTemplateAttributeValue.create(ptav_to_create) self.product_tmpl_id._create_variant_ids()