Skip to content

feat(registrant_gis): show latitude/longitude inputs on registrant form (#1143) - #324

Merged
emjay0921 merged 7 commits into
19.0from
fix/1143-gis-latlong-fields
Aug 20, 2026
Merged

feat(registrant_gis): show latitude/longitude inputs on registrant form (#1143)#324
emjay0921 merged 7 commits into
19.0from
fix/1143-gis-latlong-fields

Conversation

@emjay0921

Copy link
Copy Markdown
Contributor

Why is this change needed?

On the registry group/individual form, GPS Coordinates only render as the MapTiler map widget. Without MapTiler configured you cannot set coordinates by clicking the map, so the values are effectively un-enterable when creating a group via the registry (OP#1143). Only Excel import (via headers) could set them.

How was the change implemented?

  • Added visible Latitude and Longitude float inputs (gis_latitude / gis_longitude) on res.partner, kept in sync with the existing coordinates point:
    • computed from coordinates (x = longitude, y = latitude),
    • inverse rebuilds the point when either is typed; (0, 0) clears it,
    • stored, so editing the map updates the inputs and vice-versa.
  • Showed both inputs above the GPS Coordinates map in the Location section of the individual and group registrant forms.
  • Because they are real fields, they are also importable by name (in addition to the existing coordinates header).

New unit tests

  • test_lat_long_computed_from_coordinates — setting coordinates populates the lat/long inputs.
  • test_coordinates_built_from_lat_long — typing lat/long rebuilds the coordinates point (x=lon, y=lat).
  • test_lat_long_empty_when_no_coordinates — no point ⇒ inputs read 0.

Unit tests executed by the author

spp_registrant_gis suite: 0 failed, 0 error(s) of 7 tests (fresh DB, --stop-after-init).

How to test manually

  1. Registry → Groups → New → scroll to Location: Latitude and Longitude inputs are visible above the map.
  2. Type e.g. Latitude 8.5, Longitude 124.75, save → the map marker moves to that point.
  3. Conversely, click a point on the map (if MapTiler is configured) → the Latitude/Longitude inputs fill in.
  4. Same on the individual form.

Related links

https://projects.acn.fr/work_packages/1143

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.42857% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 68.60%. Comparing base (99f07a2) to head (ec7ac09).

Files with missing lines Patch % Lines
spp_registrant_gis/models/res_partner.py 96.42% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             19.0     #324      +/-   ##
==========================================
- Coverage   74.88%   68.60%   -6.29%     
==========================================
  Files         515      123     -392     
  Lines       35099    12412   -22687     
==========================================
- Hits        26284     8515   -17769     
+ Misses       8815     3897    -4918     
Flag Coverage Δ
spp_analytics ?
spp_api_v2_change_request ?
spp_api_v2_cycles ?
spp_api_v2_data ?
spp_api_v2_entitlements ?
spp_api_v2_gis ?
spp_api_v2_programs ?
spp_api_v2_service_points ?
spp_api_v2_simulation ?
spp_attachment_av_scan ?
spp_base_common 91.07% <ø> (ø)
spp_case_entitlements ?
spp_case_programs ?
spp_change_request_v2 ?
spp_claim_169 ?
spp_cr_type_assign_program ?
spp_dci ?
spp_dci_client ?
spp_dci_client_compliance ?
spp_dci_client_crvs ?
spp_dci_client_dr ?
spp_dci_client_ibr ?
spp_dci_compliance ?
spp_dci_demo 94.28% <ø> (ø)
spp_dci_indicators ?
spp_dci_server ?
spp_dci_server_social ?
spp_drims ?
spp_drims_sl_demo ?
spp_farmer_registry_cr ?
spp_farmer_registry_demo 63.43% <ø> (ø)
spp_grm_cel ?
spp_hazard ?
spp_key_management ?
spp_mis_demo_v2 70.38% <ø> (ø)
spp_oauth ?
spp_program_geofence 97.04% <ø> (?)
spp_programs 65.53% <ø> (ø)
spp_registrant_gis 96.96% <96.42%> (?)
spp_registry 87.22% <ø> (+0.07%) ⬆️
spp_security 69.56% <ø> (ø)
spp_starter_sp_mis ?
spp_studio_change_requests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
spp_registrant_gis/models/res_partner.py 96.77% <96.42%> (ø)

... and 410 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@emjay0921
emjay0921 marked this pull request as draft July 27, 2026 08:27
QA round 1 on OP#1143: entering an impossible latitude or longitude threw
an Odoo error and left the record unrecoverable.

The value was accepted and stored, and the MapTiler widget then failed
projecting the point — "Cannot read properties of undefined (reading '0')"
out of unproject/pointCoordinate. It fired on mouseover, so it recurred
every time the form was opened and the bad value could not be corrected.

Constrain latitude to [-90, 90] and longitude to [-180, 180]. The write is
refused, so nothing out of range is ever stored and the widget is never
handed a point it cannot project; the user sees an ordinary validation
message naming the field and the offending value, with the form still in
front of them.

Constrained on `coordinates` as well as the two inputs, so a point arriving
from an import or written directly by another module is checked on the same
terms as one typed into the form. The bounds are the poles and the
antimeridian inclusive — those are real places.

Does not clean up rows saved before this existed. An out-of-range point
already on file still breaks the widget until it is corrected or the
database is reset, which the QA note covers.

OP#1143
@emjay0921
emjay0921 marked this pull request as ready for review August 13, 2026 05:41

@gonzalesedwin1123 gonzalesedwin1123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One mechanical blocker; everything substantive is already right, including things done before they could be asked for.

What I verified:

  • The range constraint is exactly what this needed — and the story behind it (QA round 1: an impossible latitude was stored, the MapTiler widget threw while projecting it on every reopen, and the record could not be corrected) justifies both the constraint and its shape. Applying it to coordinates as well means imports and other modules face the same rule as the typed inputs — the import test proves it. This is the same guard #393 added for POD GPS, done here unprompted, with better tests: boundaries accepted (poles, antimeridian), both signs refused, and the recoverability test pinning that a refused write leaves the last good value intact — which was the actual harm.
  • The sync design is sound: compute from the point (x=lon, y=lat), inverse rebuilds it, (0, 0) documented as the unset sentinel — safe in this domain — and the defensive geom_type check keeps a non-point geometry from breaking the compute. digits=(9, 6) gives ~0.1 m precision and fits ±180. The readonly="disabled" on the new inputs matches the existing field's pattern on both forms.
  • Because they're real fields, importability-by-name comes free, as the PR says.

Blocker — version bump

spp_registrant_gis stays at 19.0.2.0.0 and ships in 2026.08. It matters functionally here: the two new stored columns and the view changes need -u spp_registrant_gis, and the views are the user-facing fix — without an upgrade, nobody sees the inputs.

One thing worth saying so nobody adds an unnecessary migration: no backfill script is needed. New stored computed fields are auto-computed when their columns are created during upgrade, so existing registrants' latitude/longitude populate from coordinates on their own — the bump is the complete upgrade story (unlike the #416 case, where existing columns changed meaning).

With the bump + HISTORY entry, this is an approve. This module is independent of the spp_drims queue, so no renumbering coordination applies.

The review's one blocker: 19.0.2.1.0 with its changelog entry. Functionally
required — the two new stored columns and the view changes need an upgrade, and
the views are the user-facing fix.

No backfill script: new stored computes are populated when their columns are
created during upgrade, so existing registrants get their latitude and longitude
from coordinates on their own.
@emjay0921
emjay0921 merged commit f66e8a0 into 19.0 Aug 20, 2026
24 checks passed
@emjay0921
emjay0921 deleted the fix/1143-gis-latlong-fields branch August 20, 2026 09:29
@emjay0921

Copy link
Copy Markdown
Contributor Author

Thanks — bump added and merged as f66e8a0b.

Version bump — spp_registrant_gis 19.0.2.1.0 (minor, since it adds fields) with its changelog entry. Agreed it is functionally required rather than signalling: the two stored columns and the view changes need the upgrade, and the views are the fix.

And thank you for stating the no-backfill reasoning explicitly — that is the kind of thing that otherwise gets "fixed" by someone adding a migration to be safe. Recorded it in the commit message too, so the next person reading the bump sees why nothing else was needed: new stored computes populate when their columns are created, unlike the #416 case where existing columns changed meaning.

spp_registrant_gis suite: 13 tests, 0 failed. CI green across all 22 checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants