16.0-fix-geolocalization #22

Open
stephansainleger wants to merge 2 commits from 16.0-fix-geolocalization into 16.0
No description provided.
stephansainleger added 2 commits 2026-11-03 13:30:50 +00:00
In Odoo 16 the ``customer`` and ``supplier`` boolean fields on
``res.partner`` were replaced by the ``customer_rank`` /
``supplier_rank`` integer counters, but the migration kept the block
forcing them to ``False`` for public profiles. Any creation of a
public profile therefore raised
``AttributeError: 'res.partner' object has no attribute 'customer'``,
which also broke main profile creation through
``create_public_profile``.

Remove the dead block instead of porting it to the new fields: ranks
default to 0 and are only incremented on invoice posting through
``_increase_rank`` on the commercial partner, so a public profile
never becomes a customer or supplier anyway. The original intent is
preserved without redundant writes.
[FIX] partner_geolocalize_usability: avoid Nominatim HTTP 429 rejections
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 2m19s
tests / test (pull_request) Successful in 1m11s
f83f9f32e2
Backport of 84d5d27 from 18.0 (no adaptation needed: the stock
``base_geocoder._call_openstreetmap`` is identical between 16.0 and
18.0).

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.

Verified on odoo16 container (image rc_16.0-ELABORE-LIGHT, dev mount):
module install with the new data file, 5 tests 0 failed/0 error, and a
real geocoding call to Nominatim with a configured User-Agent returned
correct coordinates.
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 2m19s
tests / test (pull_request) Successful in 1m11s
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 16.0-fix-geolocalization:16.0-fix-geolocalization
git checkout 16.0-fix-geolocalization
Sign in to join this conversation.
No description provided.