[FIX] website_sale: fix concurrent update
Since forward-port, `/sale/get_combination_info_website` and `_cart_update` would lead to a concurrency error. Indeed, the session would not have an order_id at first. Then both rpc would be sent at the same time: - `cart_update` would create an order and add it in the session - `/sale/get_combination_info_website` would end up calling `_compute_cart_qty` which would call `sale_get_order` and would set the `sale_order_id` to none, just aftet the `_compute_cart_qty` would actually add an order in the session, simultaneously. closes odoo/odoo#33993 Signed-off-by: Christophe Simonis <chs@odoo.com> Co-authored-by: Romain Derie <rde@odoo.com> Co-authored-by: Christophe Simonis <chs@odoo.com> Co-authored-by: Sébastien Theys <seb@odoo.com>
This commit is contained in:
committed by
Christophe Simonis
co-authored by
Christophe Simonis
Sébastien Theys
parent
8c7423298f
commit
b14921d847
@@ -390,13 +390,13 @@ class WebsiteSale(http.Controller):
|
||||
return request.render('website.404')
|
||||
if abandoned_order.state != 'draft': # abandoned cart already finished
|
||||
values.update({'abandoned_proceed': True})
|
||||
elif revive == 'squash' or (revive == 'merge' and not request.session['sale_order_id']): # restore old cart or merge with unexistant
|
||||
elif revive == 'squash' or (revive == 'merge' and not request.session.get('sale_order_id')): # restore old cart or merge with unexistant
|
||||
request.session['sale_order_id'] = abandoned_order.id
|
||||
return request.redirect('/shop/cart')
|
||||
elif revive == 'merge':
|
||||
abandoned_order.order_line.write({'order_id': request.session['sale_order_id']})
|
||||
abandoned_order.action_cancel()
|
||||
elif abandoned_order.id != request.session['sale_order_id']: # abandoned cart found, user have to choose what to do
|
||||
elif abandoned_order.id != request.session.get('sale_order_id'): # abandoned cart found, user have to choose what to do
|
||||
values.update({'access_token': abandoned_order.access_token})
|
||||
|
||||
if order:
|
||||
|
||||
@@ -260,7 +260,8 @@ class Website(models.Model):
|
||||
sale_order = self.env['sale.order'].sudo().browse(sale_order_id).exists() if sale_order_id else None
|
||||
|
||||
if not (sale_order or force_create or code):
|
||||
request.session['sale_order_id'] = None
|
||||
if request.session.get('sale_order_id'):
|
||||
request.session['sale_order_id'] = None
|
||||
return self.env['sale.order']
|
||||
|
||||
if self.env['product.pricelist'].browse(force_pricelist).exists():
|
||||
|
||||
Reference in New Issue
Block a user