diff --git a/addons/website_sale_options/controllers/main.py b/addons/website_sale_options/controllers/main.py index f2b53d84fb9..95e981fe77c 100644 --- a/addons/website_sale_options/controllers/main.py +++ b/addons/website_sale_options/controllers/main.py @@ -23,8 +23,11 @@ class website_sale_options(website_sale): return r @http.route(['/shop/cart/update_option'], type='http', auth="public", methods=['POST'], website=True) - def cart_options_update_json(self, product_id, add_qty=1, set_qty=0, goto_shop=None, **kw): + def cart_options_update_json(self, product_id, add_qty=1, set_qty=0, goto_shop=None, lang=None, **kw): cr, uid, context, pool = request.cr, request.uid, request.context, request.registry + if lang: + context = dict(context, lang=lang) + request.website = request.website.with_context(context) order = request.website.sale_get_order(force_create=1) product = pool['product.product'].browse(cr, uid, int(product_id), context=context) @@ -57,11 +60,13 @@ class website_sale_options(website_sale): if not context.get('pricelist'): context['pricelist'] = int(pricelist) + website_context = kw.get('kwargs', {}).get('context', {}) + context = dict(context or {}, **website_context) from_currency = pool.get('product.price.type')._get_field_currency(cr, uid, 'list_price', context) to_currency = pricelist.currency_id compute_currency = lambda price: pool['res.currency']._compute(cr, uid, from_currency, to_currency, price, context=context) - product = pool['product.product'].browse(cr, uid, int(product_id), context=context) + request.website = request.website.with_context(context) return request.website._render("website_sale_options.modal", { 'product': product, diff --git a/addons/website_sale_options/static/src/js/website_sale.js b/addons/website_sale_options/static/src/js/website_sale.js index 871babd6550..2b8c042005b 100644 --- a/addons/website_sale_options/static/src/js/website_sale.js +++ b/addons/website_sale_options/static/src/js/website_sale.js @@ -27,6 +27,7 @@ $(document).ready(function () { var $a = $(this); $form.ajaxSubmit({ url: '/shop/cart/update_option', + data: {lang: openerp.website.get_context().lang}, success: function (quantity) { if (!$a.hasClass('js_goto_shop')) { window.location.href = window.location.href.replace(/shop([\/?].*)?$/, "shop/cart");