diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/website_sale/controllers/variant.py | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/website_sale/controllers/variant.py')
| -rw-r--r-- | addons/website_sale/controllers/variant.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/addons/website_sale/controllers/variant.py b/addons/website_sale/controllers/variant.py new file mode 100644 index 00000000..158d2cf9 --- /dev/null +++ b/addons/website_sale/controllers/variant.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. +from odoo import http +from odoo.http import request + +from odoo.addons.sale.controllers.variant import VariantController + +class WebsiteSaleVariantController(VariantController): + @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): + """Special route to use website logic in get_combination_info override. + This route is called in JS by appending _website to the base route. + """ + kw.pop('pricelist_id') + res = self.get_combination_info(product_template_id, product_id, combination, add_qty, request.website.get_current_pricelist(), **kw) + + carousel_view = request.env['ir.ui.view']._render_template('website_sale.shop_product_carousel', + values={ + 'product': request.env['product.template'].browse(res['product_template_id']), + 'product_variant': request.env['product.product'].browse(res['product_id']), + }) + res['carousel'] = carousel_view + return res + + @http.route(auth="public") + def create_product_variant(self, product_template_id, product_template_attribute_value_ids, **kwargs): + """Override because on the website the public user must access it.""" + return super(WebsiteSaleVariantController, self).create_product_variant(product_template_id, product_template_attribute_value_ids, **kwargs) |
