Skip to content

Commit

Permalink
[IMP] website_sale_product_assortment
Browse files Browse the repository at this point in the history
  • Loading branch information
SuShanVoong committed Feb 17, 2025
1 parent e016f16 commit a03a045
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions website_sale_product_assortment/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import variant
from . import website_sale
from . import main
34 changes: 34 additions & 0 deletions website_sale_product_assortment/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from odoo import http

from odoo.addons.website.controllers import main

from .website_sale import WebsiteSale


class Website(main.Website, WebsiteSale):
@http.route(
"/website/snippet/autocomplete", type="json", auth="public", website=True
)
def autocomplete(
self,
search_type=None,
term=None,
order=None,
limit=5,
max_nb_chars=999,
options=None,
):
allowed_product_ids, assortment_restriction = self._get_products_allowed()
if assortment_restriction:
options["allowed_product_domain"] = [
("product_variant_ids", "in", list(allowed_product_ids))
]
values = super().autocomplete(
search_type=search_type,
term=term,
order=order,
limit=limit,
max_nb_chars=max_nb_chars,
options=options,
)
return values

0 comments on commit a03a045

Please sign in to comment.