From 69c7303b712e7bcedfb5e4c575883915af8ddc2d Mon Sep 17 00:00:00 2001 From: "jerome hanke (jhk)" Date: Tue, 26 May 2020 13:19:06 +0000 Subject: [PATCH] [FIX] website_sale: default website team is set trough onchange Steps to reproduce: - Install eCommerce - Check in website setting that the sales team is website - Logout - Without being logged, buy a product (all the cart flow, until the end) - Once the flow is finished, connect with the admin - Go to website > Orders > Unpaid Orders (since only wired is set when you create the db) - Go to the tab "Other Info" of the SO you just created when buying the product Previous behavior: the sales team set in website settings is overriden during the "/shop/address" endpoint Current behavior: the team set in website settings is used for sale orders coming from website opw-2231654 closes odoo/odoo#51959 X-original-commit: 919077638bc9e8a5ad1c800b629aa0eaa079f571 Signed-off-by: Nicolas Lempereur (nle) Signed-off-by: mightyjol --- addons/sale/models/sale.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index a1900198ce3..71df75c4d8a 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -375,7 +375,8 @@ class SaleOrder(models.Model): if self.env['ir.config_parameter'].sudo().get_param('account.use_invoice_terms') and self.env.company.invoice_terms: values['note'] = self.with_context(lang=self.partner_id.lang).env.company.invoice_terms - values['team_id'] = self.env['crm.team']._get_default_team_id(domain=['|', ('company_id', '=', self.company_id.id), ('company_id', '=', False)],user_id=user_id) + if not self.env.context.get('not_self_saleperson') or not self.team_id: + values['team_id'] = self.env['crm.team']._get_default_team_id(domain=['|', ('company_id', '=', self.company_id.id), ('company_id', '=', False)],user_id=user_id) self.update(values) @api.onchange('user_id')