summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNans Lefebvre <len@odoo.com>2019-03-27 12:54:43 +0000
committerNans Lefebvre <len@odoo.com>2019-03-29 11:33:00 +0000
commit6b9b9d8997d71908f44fe605b69a94ad03d4f916 (patch)
tree25d0c9dac2a46cd65c8921c63944261bda800a05
parent14a8148e8dc6a599ec1ff1e31d3fd3a64d57a415 (diff)
[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 e6ca846c65bd 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>
-rw-r--r--addons/base_geolocalize/i18n/base_geolocalize.pot24
-rw-r--r--addons/base_geolocalize/models/res_partner.py8
2 files changed, 30 insertions, 2 deletions
diff --git a/addons/base_geolocalize/i18n/base_geolocalize.pot b/addons/base_geolocalize/i18n/base_geolocalize.pot
index 6285bc757dd..b27ba8e9723 100644
--- a/addons/base_geolocalize/i18n/base_geolocalize.pot
+++ b/addons/base_geolocalize/i18n/base_geolocalize.pot
@@ -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 ""
diff --git a/addons/base_geolocalize/models/res_partner.py b/addons/base_geolocalize/models/res_partner.py
index 4c36ffe9207..ffbfc550c6b 100644
--- a/addons/base_geolocalize/models/res_partner.py
+++ b/addons/base_geolocalize/models/res_partner.py
@@ -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']