[FIX] product: variant num w/o prefetch pollution
When getting: - product_variant_count, - sales_count, of a product.product, we would pollute the records to be prefetched by all the variants when counting the number of variants. Thus if this happened before sales_count, we would possibly compute the sales_count for up to 1000 records when it could have been needed for just one. By using `.with_prefetch()`, a recordset will have its own records to be prefetched list and will not pollute the original one. opw-1865111 fixes #25649 closes #23112 (PR with similar fix) closes #25741
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user