Skip to content
Browse files

[FIX] *: remove buggy calls to with_context

When .with_context() is called with a dictionary as 1st positional
argument, it will replace context (and not modify the referenced keys)
It may create bugs when losing the content of the context (e.g. remove
partner's language)

This is a partial backport of #36164 with the website part as

closes #36692

Signed-off-by: Martin Trigaux (mat) <>
  • Loading branch information...
Yajo authored and mart-e committed Aug 28, 2019
1 parent 1ebf5cc commit 921f5ffdc9810ae7c66c0fd51a2908052a7d4ac5
@@ -38,7 +38,7 @@ def google_map(self, *arg, **post):
"counter": len(partners),
"partners": []
for partner in partners.with_context({'show_address': True}):
for partner in partners.with_context(show_address=True):
# TODO in master, do not use `escape` but `t-esc` in the qweb template.
@@ -979,7 +979,7 @@ def tracking_cart(self, **post):

@http.route(['/shop/get_unit_price'], type='json', auth="public", methods=['POST'], website=True)
def get_unit_price(self, product_ids, add_qty, **kw):
products = request.env['product.product'].with_context({'quantity': add_qty}).browse(product_ids)
products = request.env['product.product'].with_context(quantity=add_qty).browse(product_ids)
return { product.website_price / add_qty for product in products}

# ------------------------------------------------------
@@ -10,7 +10,7 @@ class WebsiteSaleOptions(WebsiteSale):
@http.route(['/shop/product/<model("product.template"):product>'], type='http', auth="public", website=True)
def product(self, product, category='', search='', **kwargs):
r = super(WebsiteSaleOptions, self).product(product, category, search, **kwargs)
r.qcontext['optional_product_ids'] = map(lambda p: p.with_context({'active_id':}), product.optional_product_ids)
r.qcontext['optional_product_ids'] = map(lambda p: p.with_context(, product.optional_product_ids)
return r

@http.route(['/shop/cart/update_option'], type='http', auth="public", methods=['POST'], website=True, multilang=False)

0 comments on commit 921f5ff

Please sign in to comment.
You can’t perform that action at this time.