diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py index f8a4ffea081..9056d40972b 100644 --- a/addons/product/models/product_template.py +++ b/addons/product/models/product_template.py @@ -250,7 +250,8 @@ class ProductTemplate(models.Model): @api.one @api.depends('product_variant_ids.product_tmpl_id') def _compute_product_variant_count(self): - self.product_variant_count = len(self.product_variant_ids) + # do not pollute variants to be prefetched when counting variants + self.product_variant_count = len(self.with_prefetch().product_variant_ids) @api.depends('product_variant_ids', 'product_variant_ids.default_code') def _compute_default_code(self):