[FIX] base_geolocalize: use urllib2 to make request
For an unknown reason, in some case, urllib doesn't work while with urllib2 it works. Since we don't have the opposite case until now (work in urllib and not urllib2), we considere that it fixes the issue. this commit closes #14636
This commit is contained in:
parent
f0c34f0df8
commit
f4aa509283
|
@ -23,7 +23,7 @@ try:
|
|||
import simplejson as json
|
||||
except ImportError:
|
||||
import json # noqa
|
||||
import urllib
|
||||
import urllib2
|
||||
|
||||
from openerp.osv import osv, fields
|
||||
from openerp import tools
|
||||
|
@ -32,10 +32,10 @@ from openerp.tools.translate import _
|
|||
|
||||
def geo_find(addr):
|
||||
url = 'https://maps.googleapis.com/maps/api/geocode/json?sensor=false&address='
|
||||
url += urllib.quote(addr.encode('utf8'))
|
||||
url += urllib2.quote(addr.encode('utf8'))
|
||||
|
||||
try:
|
||||
result = json.load(urllib.urlopen(url))
|
||||
result = json.load(urllib2.urlopen(url))
|
||||
except Exception, e:
|
||||
raise osv.except_osv(_('Network error'),
|
||||
_('Cannot contact geolocation servers. Please make sure that your internet connection is up and running (%s).') % e)
|
||||
|
|
Loading…
Reference in New Issue