[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 e6ca846c65
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: Nans Lefebvre (len) <len@odoo.com>
This commit is contained in:
@@ -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']
|
||||
|
||||
Reference in New Issue
Block a user