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 #40013

X-original-commit: ed20951
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
  • Loading branch information...
wtaferner authored and fw-bot committed Oct 30, 2019
1 parent 32f30e0 commit 9f1366e19077c556d7651515430ceb38baf81442
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 9f1366e

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