diff --git a/website_sale_product_assortment/controllers/__init__.py b/website_sale_product_assortment/controllers/__init__.py index 97b95b7d8c..22c199535e 100644 --- a/website_sale_product_assortment/controllers/__init__.py +++ b/website_sale_product_assortment/controllers/__init__.py @@ -1,2 +1,3 @@ from . import variant from . import website_sale +from . import main diff --git a/website_sale_product_assortment/controllers/main.py b/website_sale_product_assortment/controllers/main.py new file mode 100644 index 0000000000..a2fca0b457 --- /dev/null +++ b/website_sale_product_assortment/controllers/main.py @@ -0,0 +1,27 @@ +from odoo import http + +from odoo.addons.website.controllers import main + +from .website_sale import WebsiteSale + + +class Website(main.Website): + @http.route() + def autocomplete( + self, + options=None, + **kwargs, + ): + ( + allowed_product_ids, + assortment_restriction, + ) = WebsiteSale()._get_products_allowed() + if assortment_restriction: + options["allowed_product_domain"] = [ + ("product_variant_ids", "in", list(allowed_product_ids)) + ] + values = super().autocomplete( + options=options, + **kwargs, + ) + return values