summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxmo-odoo <xmo@odoo.com>2017-06-09 12:26:38 +0200
committerGitHub <noreply@github.com>2017-06-09 12:26:38 +0200
commit74a89bcf5c656a0a64f2a699444d39739ff7f1d2 (patch)
treeb07177859d17bdc9eee3a9754e8ec742998d57ff
parentbd4da1b7499a27f1460bd67bf83e697a18753b5b (diff)
[FIX] base_geolocalize: geocode errors out on empty address
It's unclear whether that's a recent change or a long-standing issue, however currently if geocode is called with an empty address string it will reply with a 400 Bad Request, which gets raised as an exception and forwarded to the user. That is not a great experience. Shortcut the entire thing and just return None (= geolocation failed / no geolocation) on trying to geolocate an empty address. OPW-746686
-rw-r--r--addons/base_geolocalize/models/res_partner.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/addons/base_geolocalize/models/res_partner.py b/addons/base_geolocalize/models/res_partner.py
index 778a844ad83..44fa8d9692f 100644
--- a/addons/base_geolocalize/models/res_partner.py
+++ b/addons/base_geolocalize/models/res_partner.py
@@ -8,6 +8,8 @@ from odoo.exceptions import UserError
def geo_find(addr):
+ if not addr:
+ return None
url = 'https://maps.googleapis.com/maps/api/geocode/json?sensor=false&address='
url += urllib2.quote(addr.encode('utf8'))