[FIX] account: crash in vat portal management

Correctly check 'vat' key is in the dict of data the user gives to
the controller and not in a browse record.
This commit is contained in:
Thibault Delavallée
2017-08-08 13:53:00 +02:00
parent 159975ba42
commit 44af9e7a35
@@ -97,7 +97,7 @@ class PortalAccount(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 'vat' in partner and (data['vat'] or False) != (partner.vat or False):
if 'vat' in data 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 'name' in data and (data['name'] or False) != (partner.name or False):