[FIX] product: count only active pricelists

Problem:
When we are in the form view of a product variant, the smart button "Extra Price" shows the number of pricelists for this variant including the archived ones

Steps to reproduce:
- Install "Sales" app and activate the pricelists
- Create a product and some variants
- Create at least one pricelist for a variant
- Archive at least one of these pricelist
- Go on the form view of the variant and take a look at the smart button which shows the number of pricelists including the archived ones

Cause:
The domain that filters the pricelists doesn't take in consideration whether the pricelist is active

opw-3836973

closes odoo/odoo#160876

Signed-off-by: Axel Trémaudant (axtr) <axtr@odoo.com>
This commit is contained in:
axtr
2024-04-17 22:47:10 +00:00
parent 54edf86bd2
commit 80f72ccb2e
+6 -3
View File
@@ -304,9 +304,12 @@ class ProductProduct(models.Model):
def _compute_variant_item_count(self):
for product in self:
domain = ['|',
'&', ('product_tmpl_id', '=', product.product_tmpl_id.id), ('applied_on', '=', '1_product'),
'&', ('product_id', '=', product.id), ('applied_on', '=', '0_product_variant')]
domain = [
('pricelist_id.active', '=', True),
'|',
'&', ('product_tmpl_id', '=', product.product_tmpl_id.id), ('applied_on', '=', '1_product'),
'&', ('product_id', '=', product.id), ('applied_on', '=', '0_product_variant'),
]
product.pricelist_item_count = self.env['product.pricelist.item'].search_count(domain)
def _compute_product_document_count(self):