Skip to content
Snippets Groups Projects
Commit 1d6ae6bb authored by Thomas Lefebvre (thle)'s avatar Thomas Lefebvre (thle)
Browse files

[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#122121

Signed-off-by: default avatarAntoine Vandevenne (anv) <anv@odoo.com>
parent cf45800d
No related branches found
No related tags found
No related merge requests found
...@@ -579,7 +579,7 @@ class WebsiteSale(http.Controller): ...@@ -579,7 +579,7 @@ class WebsiteSale(http.Controller):
# prevent name change if invoices exist # prevent name change if invoices exist
if data.get('partner_id'): if data.get('partner_id'):
partner = request.env['res.partner'].browse(int(data['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['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.')) error_message.append(_('Changing your name is not allowed once invoices have been issued for your account. Please contact us directly for this operation.'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment