Skip to content

Commit

Permalink
[FIX] account: method zipcode.isdigit is not sufficient enough
Browse files Browse the repository at this point in the history
instead we do a simple try/except and catch the ValueError

closes #40014

X-original-commit: ed20951
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
  • Loading branch information
wtaferner authored and fw-bot committed Nov 8, 2019
1 parent 9f46dc7 commit d0e68c6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions addons/account/models/partner.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@ def _get_fpos_by_region(self, country_id=False, state_id=False, zipcode=False, v
null_zip_dom = zip_domain = [('zip_from', '=', 0), ('zip_to', '=', 0)] null_zip_dom = zip_domain = [('zip_from', '=', 0), ('zip_to', '=', 0)]
null_country_dom = [('country_id', '=', False), ('country_group_id', '=', False)] null_country_dom = [('country_id', '=', False), ('country_group_id', '=', False)]


if zipcode and zipcode.isdigit(): # DO NOT USE zipcode.isdigit() b/c '4020²' would be true, so we try/except
try:
zipcode = int(zipcode) zipcode = int(zipcode)
zip_domain = [('zip_from', '<=', zipcode), ('zip_to', '>=', zipcode)] if zipcode != 0:
else: zip_domain = [('zip_from', '<=', zipcode), ('zip_to', '>=', zipcode)]
except (ValueError, TypeError):
zipcode = 0 zipcode = 0


if state_id: if state_id:
Expand Down

0 comments on commit d0e68c6

Please sign in to comment.