Skip to content

Commit

Permalink
[FIX] {website_,}sale: no salesperson better than customer
Browse files Browse the repository at this point in the history
Before 13.0, when there is no salesperson on the customer or company or
website, when a ecommerce sale order is done we get the OdooBot as
salesperson because we update partner on sale order in superuser.

In 13.0, since superuser doesn't change UID, the salesperson will be
assigned to "Public User" or the customer that create this order.

opw-2232201
closes odoo#49141

Signed-off-by: Nicolas Lempereur (nle) <[email protected]>
  • Loading branch information
nle-odoo committed Apr 7, 2020
1 parent e69c080 commit 0b6a256
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion addons/sale/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,9 @@ def onchange_partner_id(self):
'partner_invoice_id': addr['invoice'],
'partner_shipping_id': addr['delivery'],
}
user_id = partner_user.id or self.env.uid
user_id = partner_user.id
if not self.env.context.get('not_self_saleperson'):
user_id = user_id or self.env.uid
if self.user_id.id != user_id:
values['user_id'] = user_id

Expand Down
2 changes: 1 addition & 1 deletion addons/website_sale/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ def address(self, **kw):
partner_id = self._checkout_form_save(mode, post, kw)
if mode[1] == 'billing':
order.partner_id = partner_id
order.onchange_partner_id()
order.with_context(not_self_saleperson=True).onchange_partner_id()
# This is the *only* thing that the front end user will see/edit anyway when choosing billing address
order.partner_invoice_id = partner_id
if not kw.get('use_same'):
Expand Down
2 changes: 1 addition & 1 deletion addons/website_sale/models/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def sale_get_order(self, force_create=False, code=None, update_pricelist=False,

# change the partner, and trigger the onchange
sale_order.write({'partner_id': partner.id})
sale_order.onchange_partner_id()
sale_order.with_context(not_self_saleperson=True).onchange_partner_id()
sale_order.write({'partner_invoice_id': partner.id})
sale_order.onchange_partner_shipping_id() # fiscal position
sale_order['payment_term_id'] = self.sale_get_payment_term(partner)
Expand Down

0 comments on commit 0b6a256

Please sign in to comment.