[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#134376 X-original-commit: 160e8bfbf72a3e5d7cc8d8cbe7bc4f310f298baa Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com> Signed-off-by: Arnaud Joset (arj) <arj@odoo.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user