From f58223ca25cafdbc97ae3b75f290c26a1861fb49 Mon Sep 17 00:00:00 2001 From: Pablo Calvo Espinar Date: Tue, 15 Oct 2024 12:02:35 +0200 Subject: [PATCH] [FIX] website_sale_product_assortment: dont restrict other assortment products --- .../models/product_template.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/website_sale_product_assortment/models/product_template.py b/website_sale_product_assortment/models/product_template.py index 3f96895afd..e26a84fc79 100644 --- a/website_sale_product_assortment/models/product_template.py +++ b/website_sale_product_assortment/models/product_template.py @@ -16,19 +16,26 @@ def get_product_assortment_restriction_info(self, product_ids): .search( [ ("is_assortment", "=", True), - ("website_availability", "in", ["no_purchase", "no_show"]), + ("website_availability", "in", ["no_purchase", "no_restriction"]), "|", ("website_ids", "=", website.id), ("website_ids", "=", False), ] ) ) - assortment_dict = {} + partner_assortments = self.env["ir.filters"].sudo() + + allowed_product_ids = set() for assortment in assortments: if partner & assortment.with_context(active_test=False).all_partner_ids: - allowed_product_ids = assortment.all_product_ids.ids - for product in product_ids: - if product not in allowed_product_ids: + partner_assortments |= assortment + allowed_product_ids.update(assortment.all_product_ids.ids) + + assortment_dict = {} + for product in product_ids: + if product not in allowed_product_ids: + for assortment in partner_assortments: + if product not in assortment.all_product_ids.ids: assortment_dict.setdefault(product, self.env["ir.filters"]) assortment_dict[product] |= assortment return assortment_dict