Skip to content

Commit

Permalink
[REF] base_vat_autocomplete: Compatibility with python-stdnum>=1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
moylop260 committed Apr 24, 2018
1 parent b9ce1af commit 3885b2f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion addons/base_vat_autocomplete/models/res_partner.py
Expand Up @@ -12,6 +12,8 @@

try:
import stdnum.eu.vat as stdnum_vat
if not hasattr(stdnum_vat, "_country_codes"):
stdnum_vat._country_codes = stdnum_vat.country_codes
except ImportError:
_logger.warning('Python `stdnum` library not found, unable to call VIES service to detect address based on VAT number.')
stdnum_vat = None
Expand Down Expand Up @@ -49,7 +51,7 @@ def _set_address_field(partner, field, value):
non_set_address_fields = set(['street', 'street2', 'city', 'zip', 'state_id', 'country_id'])
if not partner.vat:
return {}
if len(partner.vat) > 5 and partner.vat[:2].lower() in stdnum_vat.country_codes:
if len(partner.vat) > 5 and partner.vat[:2].lower() in stdnum_vat._country_codes:
# Equivalent to stdnum_vat.check_vies(partner.vat).
# However, we want to add a custom timeout to the suds.client
# because by default, it's 120 seconds and this is to long.
Expand Down

0 comments on commit 3885b2f

Please sign in to comment.