From 9526db300e5c7eb10c7ac0829c568ec1f1b7bfd1 Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Thu, 29 Mar 2018 12:21:46 -0600 Subject: [PATCH 1/2] [IMP] Products in subcategories are equivalents and can be excluded --- mrp_bom_equivalent/models/product.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mrp_bom_equivalent/models/product.py b/mrp_bom_equivalent/models/product.py index c1137a0a4..2f23c280f 100644 --- a/mrp_bom_equivalent/models/product.py +++ b/mrp_bom_equivalent/models/product.py @@ -13,7 +13,7 @@ class ProductProduct(models.Model): category_id = self.browse( self._context.get('nonequivalent_product_id')).categ_id recs = self.search( - [('categ_id', '=', category_id.id), + [('categ_id', 'child_of', category_id.id), ('id', '!=', self._context.get('nonequivalent_product_id')), ('name', operator, name)] + args, limit=limit) if not recs: @@ -30,7 +30,7 @@ class ProductProduct(models.Model): category_id = self.browse( self._context.get('nonequivalent_product_id')).categ_id domain +=\ - [('categ_id', '=', category_id.id), + [('categ_id', 'child_of', category_id.id), ('id', '!=', self._context.get('nonequivalent_product_id'))] order = order or self.priority return super(ProductProduct, self).search_read(domain=domain, From c433bfdf173819774c79f503224657433c8e332e Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Tue, 12 Jun 2018 10:36:21 -0500 Subject: [PATCH 2/2] Update product.py --- mrp_bom_equivalent/models/product.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mrp_bom_equivalent/models/product.py b/mrp_bom_equivalent/models/product.py index 2f23c280f..3bf163d31 100644 --- a/mrp_bom_equivalent/models/product.py +++ b/mrp_bom_equivalent/models/product.py @@ -32,7 +32,7 @@ class ProductProduct(models.Model): domain +=\ [('categ_id', 'child_of', category_id.id), ('id', '!=', self._context.get('nonequivalent_product_id'))] - order = order or self.priority + order = order or self.product_tmpl_id.priority return super(ProductProduct, self).search_read(domain=domain, fields=fields, offset=offset,