[FIX] website_portal_sale: fix vat and name comparison in /my/account

Before this commit, we compare in some case False != u''

Commit #56c798a fix u'' != False but in case of the partner has been
edited from front end, partner.vat will be u'' and not False
This commit is contained in:
Jeremy Kersten
2017-05-16 17:47:51 +02:00
parent 490764ae11
commit 5bbe4a8ce7
@@ -178,10 +178,10 @@ class website_account(website_account):
partner = request.env['res.users'].browse(request.uid).partner_id
invoices = request.env['account.invoice'].sudo().search_count([('partner_id', '=', partner.id), ('state', 'not in', ['draft', 'cancel'])])
if invoices:
if (data.get('vat', partner.vat) or False) != partner.vat:
if 'vat' in partner and (data['vat'] or False) != (partner.vat or False):
error['vat'] = 'error'
error_message.append(_('Changing VAT number is not allowed once invoices have been issued for your account. Please contact us directly for this operation.'))
if data.get('name', partner.name) != partner.name:
if '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.'))
return error, error_message