Browse files

[FIX] website_sale: performance when creating a cart

- When creating an eCommerce cart using the Public User, the code tries
  to access all the sale orders linked to it.

  Depending on the count of sale orders linked to the partner, the
  loading can take a lot of time.

  To avoid this, we only search for the sale orders of connected users
  and we only retrieve the last one.
  • Loading branch information...
tbe-odoo committed Oct 26, 2018
1 parent ae3997b commit fe518f1feaabc0101e201b2542acf18deca9693f
Showing with 4 additions and 2 deletions.
  1. +4 −2 addons/website_sale/models/
@@ -161,8 +161,10 @@ def _prepare_sale_order_values(self, partner, pricelist):
affiliate_id = request.session.get('affiliate_id')
salesperson_id = affiliate_id if self.env['res.users'].sudo().browse(affiliate_id).exists() else
addr = partner.address_get(['delivery', 'invoice'])
if len(partner.sale_order_ids): # first = me
addr['delivery'] = partner.sale_order_ids[0]
if not
last_sale_order = self.env['sale.order'].search([('partner_id', '=',], limit=1, order="date_order desc, id desc")
if last_sale_order: # first = me
addr['delivery'] =
default_user_id = or
values = {

0 comments on commit fe518f1

Please sign in to comment.