Skip to content
Permalink
Browse files

[FIX] account: method zipcode.isdigit is not sufficient enough

instead we do a simple try/except and catch the ValueError

closes #39588

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
  • Loading branch information...
wtaferner committed Oct 30, 2019
1 parent 77ed190 commit ed20951af7ffaa50b9cdca8ef4eb0d5b1a9f8caa
Showing with 5 additions and 3 deletions.
  1. +5 −3 addons/account/models/partner.py
@@ -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_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)
zip_domain = [('zip_from', '<=', zipcode), ('zip_to', '>=', zipcode)]
else:
if zipcode != 0:
zip_domain = [('zip_from', '<=', zipcode), ('zip_to', '>=', zipcode)]
except (ValueError, TypeError):
zipcode = 0

if state_id:

0 comments on commit ed20951

Please sign in to comment.
You can’t perform that action at this time.