Skip to content
Snippets Groups Projects
Commit 160e8bfb authored by Arnaud Joset's avatar Arnaud Joset
Browse files

[FIX] base_geolocalize: allow to override user agent with system parameter

Before this commit, the useragent was harcoded as an Odoo one and if it was
blacklisted by the osmfoundation policy https://operations.osmfoundation.org/policies/nominatim/


all Odoo instances were forbidden to access the service.

This parameter allows to override the user agent with a system parameter.

closes odoo/odoo#134131

Signed-off-by: default avatarYannick Tivisse (yti) <yti@odoo.com>
parent 814fb43e
No related branches found
No related tags found
No related merge requests found
......@@ -87,7 +87,8 @@ class GeoCoder(models.AbstractModel):
return None
url = 'https://nominatim.openstreetmap.org/search'
try:
headers = {'User-Agent': 'Odoo (http://www.odoo.com/contactus)'}
headers = {'User-Agent': self.env['ir.config_parameter'].get_param('base_geolocalize.user_agent',
'Odoo (http://www.odoo.com/contactus)')}
response = requests.get(url, headers=headers, params={'format': 'json', 'q': addr})
_logger.info('openstreetmap nominatim service called')
if response.status_code != 200:
......
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