[FIX] partner_autocomplete: fix traceback in vat number matching
This issue is occurring when the user tries to add a VAT number while creating a new contact To reproduce this issue: 1) Install "contacts" and "partner_autocomplete" 2) Create a new contact from 'Contacts' 3) Give a valid VAT number e.g:- "SK2120312645" 4) Traceback occurs in the terminal Error:- "IndexError: list index out of range" https://github.com/odoo/odoo/blob/382b64c2f14073cfff1a8ef9290b5c7834d52188/addons/partner_autocomplete/models/res_partner.py#L143-L156 In some cases, the expected "zip_city" value is not at the last of the address list , which leads to a traceback. After applying this commit will resolve this issue by searching "zip_city" based on regex. sentry-5058467547 closes odoo/odoo#158580 X-original-commit: 55c605f44d3a4f280946f1c1fec3f5e1534b4ef9 Signed-off-by: Louis Baudoux (lba) <lba@odoo.com> Signed-off-by: Altaf Shaik (alsh) <alsh@odoo.com>
This commit is contained in:
@@ -148,8 +148,9 @@ class ResPartner(models.Model):
|
||||
if vies_result['valid'] and name != '---':
|
||||
address = list(filter(bool, vies_result['address'].split('\n')))
|
||||
street = address[0]
|
||||
zip_city = address[-1].split(' ', 1) if len(address) > 1 else [None, None]
|
||||
street2 = address[1] if len(address) > 2 else None
|
||||
zip_city_record = next(filter(lambda addr: re.match(r'^\d.*', addr), address[1:]), None)
|
||||
zip_city = zip_city_record.split(' ', 1) if zip_city_record else [None, None]
|
||||
street2 = next((addr for addr in filter(lambda addr: addr != zip_city_record, address[1:])), None)
|
||||
return [self._iap_replace_location_codes({
|
||||
'name': name,
|
||||
'vat': vat,
|
||||
|
||||
Reference in New Issue
Block a user