Skip to content

Commit

Permalink
[FIX] base_geolocalize, website_crm_partner_assign: geolocalize fallb…
Browse files Browse the repository at this point in the history
…ack on city

If the street cannot be localized, we retry with only the city.
  • Loading branch information
JKE-be committed Dec 7, 2016
1 parent d3ea014 commit 7d96811
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions addons/base_geolocalize/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def geo_find(addr):
result = json.load(urllib.urlopen(url))
except Exception as e:
raise UserError(_('Cannot contact geolocation servers. Please make sure that your Internet connection is up and running (%s).') % e)

if result['status'] != 'OK':
return None

Expand Down Expand Up @@ -52,6 +53,13 @@ def geo_localize(self):
city=partner.city,
state=partner.state_id.name,
country=partner.country_id.name))
if result is None:
result = geo_find(geo_query_address(
city=partner.city,
state=partner.state_id.name,
country=partner.country_id.name
))

if result:
partner.write({
'partner_latitude': result[0],
Expand Down
8 changes: 8 additions & 0 deletions addons/website_crm_partner_assign/models/crm_lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ def assign_geo_localize(self, latitude=False, longitude=False):
city=lead.city,
state=lead.state_id.name,
country=lead.country_id.name))

if result is None:
result = geo_find(geo_query_address(
city=lead.city,
state=lead.state_id.name,
country=lead.country_id.name
))

if result:
lead.write({
'partner_latitude': result[0],
Expand Down

0 comments on commit 7d96811

Please sign in to comment.