[FIX] website_sale: allow setting name for delivery

Fixup for d823033ad67702b1b92d27a3f66c7a4ec304c644

Portal user should not modify partner's name if an invoice for this partner is
already issued. However, delivery address contact may have empty name, while
eCommerce UI requires filling out the name. This blocks checkout process. Fix it
by allowing name changes, when it's not set.

opw-2981455

closes odoo/odoo#101796

X-original-commit: 781dbeaccac76a6ec4f4b8cac1b607810697e394
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
This commit is contained in:
Ivan Yelizariev
2022-09-30 21:14:53 +02:00
parent 96c590504b
commit 552ef6533c
+1 -1
View File
@@ -974,7 +974,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 not partner.sudo().can_edit_vat() and 'name' in data and (data['name'] or False) != (partner.name or False):
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):
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.'))