[CLN] website_sale,*: unnecessary pricelist context

There is no need to manually add the pricelist context for ecommerce
flows anymore, it is automatically managed in `_get_contextual_pricelist`
override of website_sale.

Part-of: odoo/odoo#121986
This commit is contained in:
Victor Feyens
2023-09-14 18:09:48 +00:00
parent 4069158c96
commit ae7d23ef2e
4 changed files with 9 additions and 27 deletions
@@ -9,13 +9,6 @@ from odoo.addons.website_event.controllers.main import WebsiteEventController
class WebsiteEventBoothController(WebsiteEventController):
@route()
def event_booth_main(self, event, booth_category_id=False, booth_ids=False):
pricelist = request.website.pricelist_id
if pricelist:
event = event.with_context(pricelist=pricelist.id)
return super(WebsiteEventBoothController, self).event_booth_main(event, booth_category_id, booth_ids)
@route()
def event_booth_registration_confirm(self, event, booth_category_id, event_booth_ids, **kwargs):
"""Override: Doesn't call the parent method because we go through the checkout
@@ -10,14 +10,6 @@ from odoo.addons.website_event.controllers.main import WebsiteEventController
class WebsiteEventSaleController(WebsiteEventController):
@route()
def event_register(self, event, **post):
if not request.context.get('pricelist'):
pricelist = request.website.pricelist_id
if pricelist:
event = event.with_context(pricelist=pricelist.id)
return super().event_register(event, **post)
def _process_tickets_form(self, event, form_details):
""" Add price information on ticket order """
res = super()._process_tickets_form(event, form_details)
+1 -4
View File
@@ -334,9 +334,6 @@ class WebsiteSale(http.Controller):
request.session['website_sale_pricelist_time'] = now
request.session['website_sale_current_pl'] = pricelist.id
partner_sudo = request.env.user.partner_id
request.update_context(pricelist=pricelist.id, partner=partner_sudo)
filter_by_price_enabled = website.is_view_active('website_sale.filter_products_price')
if filter_by_price_enabled:
company_currency = website.company_id.currency_id
@@ -442,7 +439,7 @@ class WebsiteSale(http.Controller):
request.session['website_sale_shop_layout_mode'] = layout_mode
# Try to fetch geoip based fpos or fallback on partner one
fiscal_position_id = website._get_current_fiscal_position_id(partner_sudo)
fiscal_position_id = website._get_current_fiscal_position_id(request.env.user.partner_id)
fiscal_position_sudo = website.env['account.fiscal.position'].sudo().browse(fiscal_position_id)
products_prices = lazy(lambda: products._get_sales_prices(pricelist, fiscal_position_sudo))
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from odoo import http
from odoo.http import request
from odoo.addons.website_sale.controllers.main import WebsiteSale
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import json
from odoo.http import request, route
from odoo.addons.website_sale.controllers.main import WebsiteSale
class WebsiteSaleProductComparison(WebsiteSale):
@http.route('/shop/compare', type='http', auth="public", website=True, sitemap=False)
@route('/shop/compare', type='http', auth='public', website=True, sitemap=False)
def product_compare(self, **post):
values = {}
product_ids = [int(i) for i in post.get('products', '').split(',') if i.isdigit()]
@@ -18,18 +19,17 @@ class WebsiteSaleProductComparison(WebsiteSale):
values['products'] = products.with_context(display_default_code=False)
return request.render("website_sale_comparison.product_compare", values)
@http.route(['/shop/get_product_data'], type='json', auth="public", website=True)
@route('/shop/get_product_data', type='json', auth='public', website=True)
def get_product_data(self, product_ids, cookies=None):
ret = {}
website = request.env['website'].get_current_website()
pricelist = website.pricelist_id
products = request.env['product.product'].search([('id', 'in', product_ids)])
if cookies is not None:
ret['cookies'] = json.dumps(request.env['product.product'].search([('id', 'in', list(set(product_ids + cookies)))]).ids)
products = products.with_context(pricelist=pricelist.id, display_default_code=False)
products = products.with_context(display_default_code=False)
for product in products:
ret[product.id] = {
'render': request.env['ir.ui.view']._render_template(