From e513ff1c556a84239c424cad77e413a5725fc0b9 Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Tue, 23 May 2023 13:36:00 +0000 Subject: [PATCH] [FIX] website_sale: authorise the change of shipping address Steps to reproduce: Without being logged in, complete the purchase flow on the ecommerce, taking care to have a different billing and shipping address. If you change the delivery address, you will get an access error. Cause: In some cases, we do not have access to the `name` field of the `partner` record. Solution: Add `sudo` to be able to read the fields. opw-3276877 closes odoo/odoo#122329 X-original-commit: 1d6ae6bbc765de5673fab5830a81510a1d8857ae Signed-off-by: Antoine Vandevenne (anv) Signed-off-by: Lefebvre Thomas (thle) --- addons/website_sale/controllers/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index d03fe78e36a..99ebe3a2b11 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -1002,7 +1002,7 @@ class WebsiteSale(http.Controller): # prevent name change if invoices exist if data.get('partner_id'): partner = request.env['res.partner'].browse(int(data['partner_id'])) - if partner.exists() and partner.name and not partner.sudo().can_edit_vat() and 'name' in data and (data['name'] or False) != (partner.name or False): + if partner.exists() and partner.sudo().name and not partner.sudo().can_edit_vat() and 'name' in data and (data['name'] or False) != (partner.sudo().name or False): error['name'] = 'error' error_message.append(_('Changing your name is not allowed once invoices have been issued for your account. Please contact us directly for this operation.'))