From 80f72ccb2eb2bcb651eda40367a44ffc386e356b Mon Sep 17 00:00:00 2001 From: axtr Date: Wed, 17 Apr 2024 12:03:53 +0200 Subject: [PATCH] [FIX] product: count only active pricelists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- addons/product/models/product_product.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/product/models/product_product.py b/addons/product/models/product_product.py index ab7c281158c..3174f2ba886 100644 --- a/addons/product/models/product_product.py +++ b/addons/product/models/product_product.py @@ -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):