From 2ba7114047a858fc5731b6d190e7b14e935bcfaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Rahir?= Date: Thu, 20 Jun 2019 09:27:05 +0000 Subject: [PATCH] [FIX] website_sale: multi-website MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fix added in 3a0f05f3341aacad9be08736df787882addccfd4 doesn't work if an already existing user in company A trys to modify his address on a website linked to company B. The form will try to change the company_id of the res.partner which will then conflit with the company_id of the associated res.user, ultimately leading to a UserError and a 500 error on the website. opw-2025457 closes odoo/odoo#34262 Signed-off-by: Rémi Rahir (rar) --- addons/website_sale/controllers/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 3411fb3e3b9..88a8bb27fa5 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -605,9 +605,12 @@ class WebsiteSale(ProductConfiguratorController): new_values['customer'] = True new_values['team_id'] = request.website.salesteam_id and request.website.salesteam_id.id new_values['user_id'] = request.website.salesperson_id and request.website.salesperson_id.id - new_values['company_id'] = request.website.company_id.id new_values['website_id'] = request.website.id + if order.partner_id.id == request.website.user_id.sudo().partner_id.id: + # If the partner is public, we assign the company of the website + new_values['company_id'] = request.website.company_id.id + lang = request.lang if request.lang in request.website.mapped('language_ids.code') else None if lang: new_values['lang'] = lang