The stock ``base_geocoder._call_openstreetmap`` sends a generic Odoo ``User-Agent`` shared across thousands of instances, which Nominatim rate-limits and blocks (HTTP 429 "Too many requests"), so mass geolocation fails regardless of client-side throttling. Override ``_call_openstreetmap`` to: - send a deployment-specific ``User-Agent`` read from a new system parameter ``partner_geolocalize_usability.user_agent`` (shipped with an obvious placeholder so an unconfigured instance fails loudly instead of silently reusing the banned generic agent); - throttle requests to one per second (``time.sleep``) before each call, complying with the Nominatim usage policy even when callers loop over many partners; - return ``None`` instead of raising ``IndexError`` when Nominatim returns an empty result for an unknown address. Document the required system parameter in the README and add tests covering the User-Agent selection, throttling and empty/blank results.
17 lines
762 B
XML
17 lines
762 B
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<odoo>
|
|
<!--
|
|
User-Agent sent to the OpenStreetMap Nominatim geocoding service.
|
|
|
|
Nominatim's usage policy requires a genuine User-Agent identifying the
|
|
application and a valid contact address. The value below is a PLACEHOLDER:
|
|
each deployment MUST replace it with its own service name and contact,
|
|
e.g. "acme-crm/1.0 (contact: gis@acme.example)". Leaving the placeholder
|
|
will result in HTTP 429 (Too many requests) from Nominatim.
|
|
-->
|
|
<record id="param_nominatim_user_agent" model="ir.config_parameter">
|
|
<field name="key">partner_geolocalize_usability.user_agent</field>
|
|
<field name="value">SET-ME partner_geolocalize_usability (contact: you@example.invalid)</field>
|
|
</record>
|
|
</odoo>
|