From c50745f1a1f04ce06696a5095b5ff7407e7dac60 Mon Sep 17 00:00:00 2001 From: xmo-odoo Date: Fri, 9 Jun 2017 12:26:38 +0200 Subject: [PATCH] [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 backport of 74a89bcf5c656a0a64f2a699444d39739ff7f1d2 --- addons/base_geolocalize/models/res_partner.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/base_geolocalize/models/res_partner.py b/addons/base_geolocalize/models/res_partner.py index 0b4a3ecf153..c42f8f55627 100644 --- a/addons/base_geolocalize/models/res_partner.py +++ b/addons/base_geolocalize/models/res_partner.py @@ -31,6 +31,8 @@ from openerp.tools.translate import _ 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'))