Skip to content
Snippets Groups Projects
Commit 6b9b9d89 authored by Nans Lefebvre's avatar Nans Lefebvre
Browse files

[FIX] base_geolocalize: raise a helpful error to configure the Google account


Google maps used to be free, but became a paid API.
Technically, the usage could be part of the free offer,
but to benefit from it the account needs to have billing enabled.
Since it's a paid feature security had to be ramped up,
so now APIs have to be explicitly enabled (here geolocating/geocoding).
All this makes it so that the Google account has to be properly configured
before the calls to the Maps API can work.
As a result we add an explicit UserError if the request fails,
to help the user configure the Google account
(before the error was entirely hidden as to give the user no chance at all).

Also exports transaltions, including for commit e6ca846c
which raised a similar error message if no API key was found.

opw 1946485
opw 1947292
opw 1947337

closes odoo/odoo#32162

Signed-off-by: default avatarNans Lefebvre (len) <len@odoo.com>
parent 14a8148e
No related branches found
No related tags found
No related merge requests found
......@@ -31,7 +31,17 @@ msgid "<span> ; Long: </span>"
msgstr ""
#. module: base_geolocalize
#: code:addons/base_geolocalize/models/res_partner.py:17
#: code:addons/base_geolocalize/models/res_partner.py:18
#, python-format
msgid "API key for GeoCoding (Places) required.\n"
"\n"
" Save this key in System Parameters with key: google.api_key_geocode, value: <your api key>\n"
" Visit https://developers.google.com/maps/documentation/geocoding/get-api-key for more information.\n"
" "
msgstr ""
#. module: base_geolocalize
#: code:addons/base_geolocalize/models/res_partner.py:29
#, python-format
msgid "Cannot contact geolocation servers. Please make sure that your Internet connection is up and running (%s)."
msgstr ""
......@@ -71,3 +81,15 @@ msgstr ""
msgid "Partner Assignation"
msgstr ""
#. module: base_geolocalize
#: code:addons/base_geolocalize/models/res_partner.py:34
#, python-format
msgid "Unable to geolocate, received the error:\n"
"%s\n"
"\n"
"Google made this a paid feature.\n"
"You should first enable billing on your Google account.\n"
"Then, go to Developer Console, and enable the APIs:\n"
"Geocoding, Maps Static, Maps Javascript.\n"
"error_message"
msgstr ""
......@@ -31,7 +31,13 @@ def geo_find(addr, apikey=False):
if result['status'] != 'OK':
if result.get('error_message'):
_logger.error(result['error_message'])
return None
error_msg = _('Unable to geolocate, received the error:\n%s'
'\n\nGoogle made this a paid feature.\n'
'You should first enable billing on your Google account.\n'
'Then, go to Developer Console, and enable the APIs:\n'
'Geocoding, Maps Static, Maps Javascript.\n'
% result['error_message'])
raise UserError(error_msg)
try:
geo = result['results'][0]['geometry']['location']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment