[FIX] product: Only trigger unlink when there are records to unlink

closes odoo/odoo#92663

X-original-commit: 9039380f74984878f95a4dcf9cf425a855330a38
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
Jordi Ballester
2022-06-01 17:36:45 +02:00
committed by Miquel Raïch
parent f3cbb27fc1
commit aba7ffc38d
+2 -1
View File
@@ -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()