diff --git a/website_sale_product_pack/__init__.py b/website_sale_product_pack/__init__.py index 0650744f6..f7209b171 100644 --- a/website_sale_product_pack/__init__.py +++ b/website_sale_product_pack/__init__.py @@ -1 +1,2 @@ from . import models +from . import controllers diff --git a/website_sale_product_pack/controllers/__init__.py b/website_sale_product_pack/controllers/__init__.py new file mode 100644 index 000000000..57a00ae3c --- /dev/null +++ b/website_sale_product_pack/controllers/__init__.py @@ -0,0 +1,2 @@ +from . import main +from . import variant diff --git a/website_sale_product_pack/controllers/main.py b/website_sale_product_pack/controllers/main.py new file mode 100644 index 000000000..c3d3b9b7c --- /dev/null +++ b/website_sale_product_pack/controllers/main.py @@ -0,0 +1,26 @@ +from odoo.http import request + +from odoo.addons.website_sale.controllers.main import WebsiteSale + + +class WebsiteSale(WebsiteSale): + def shop( + self, + page=0, + category=None, + search="", + min_price=0.0, + max_price=0.0, + ppg=False, + **post + ): + request.update_context(whole_pack_price=True) + return super().shop( + page=page, + category=category, + search=search, + min_price=min_price, + max_price=max_price, + ppg=ppg, + **post + ) diff --git a/website_sale_product_pack/controllers/variant.py b/website_sale_product_pack/controllers/variant.py new file mode 100644 index 000000000..7cb83264a --- /dev/null +++ b/website_sale_product_pack/controllers/variant.py @@ -0,0 +1,23 @@ +from odoo import http + +from odoo.addons.website_sale.controllers.variant import WebsiteSaleVariantController + + +class WebsiteSaleVariantController(WebsiteSaleVariantController): + @http.route( + ["/sale/get_combination_info_website"], + type="json", + auth="public", + methods=["POST"], + website=True, + ) + def get_combination_info_website( + self, product_template_id, product_id, combination, add_qty, **kw + ): + if "context" in kw: + kw["context"].update({"whole_pack_price": True}) + else: + kw["context"] = {"whole_pack_price": True} + return super(WebsiteSaleVariantController, self).get_combination_info_website( + product_template_id, product_id, combination, add_qty, **kw + )