feat(farm_field_geo): PostGIS polygon + auto-computed acreage - #2
Closed
dnplkndll wants to merge 4 commits into
Closed
feat(farm_field_geo): PostGIS polygon + auto-computed acreage#2dnplkndll wants to merge 4 commits into
dnplkndll wants to merge 4 commits into
Conversation
Extends farm.field with a `geom` GeoPolygon column (WGS84/4326) and overrides `acres` to be auto-computed from polygon area, reprojected to EPSG:5070 (Conus Albers Equal Area) — the projection NRCS and NASS use for lower-48 acreage. Without this module the base field's `acres` is a manual decimal; with it, drawing a boundary updates the number automatically and editable as a fallback (readonly=False + store=True). Depends on OCA/geospatial's `base_geoengine`. That module isn't on the upstream 19.0 branch yet — workspace `repos.yaml` forward-port-pins to OCA PR #446. Reverts to plain `oca 19.0` once that lands. In-form polygon EDITING needs `web_leaflet_draw_lib`, which has no 19.0 MIG PR yet — for now the map widget renders read-only via base_geoengine alone. Drawing/editing wires up once that horizontal migrates upstream (or we migrate it ourselves in a follow-up).
Self-review against feature-completeness + DRY + test-coverage + docs: - View: move the geom widget from after-acres (inside a 2-column group, where the map gets crushed) to its own Boundary notebook tab where it can use full width. Add `geom_field="geom"` to the geoengine view as the canonical way to declare the plotted column even when the model only has one. - Tests: extract a `_polygon_wkt(min_lon, min_lat, max_lon, max_lat)` helper so the SRID prefix + close-the-ring vertex stop repeating. Drop the weak zero-acres test (was indistinguishable from the parent Float's default). Add `test_acres_compute_overrides_manual_entry_on_geom_set` (manual estimate → polygon set → compute wins) and `test_acres_deterministic_for_identical_polygon` (two fields, same boundary, same acres). - USAGE.md: untangle the contradictory "draw … read-only" wording. Make the manual-acres-as-fallback flow explicit. - DESCRIPTION.md: add Scope (multi-plot fields → multiple farm.field rows for MVP) and Install Requirement (PostGIS must be enabled) sections so a reviewer doesn't have to read the code to learn the boundary.
This was referenced May 17, 2026
dnplkndll
added a commit
that referenced
this pull request
May 18, 2026
…y form view
The form view's header declared a `Refresh Token` button (visible when
state ∈ {connected, expired}) calling `action_refresh_token`, but the
model never shipped the method. Odoo's view validator caught it at
install time:
ParseError: while parsing farm_qbo_connection_views.xml:25
action_refresh_token is not a valid action on farm.qbo.connection
Adds the method on the model and the underlying token-refresh round-trip
on services/intuit_client.IntuitClient.refresh_access_token() — uses
intuitlib.client.AuthClient.refresh() when the libs are installed, raises
a clear UserError in stub mode. Two tests cover both paths: missing
refresh token → UserError; mocked successful refresh → connection record
updated with new access/refresh tokens + expiry.
Unblocks CI on PR #1 and the entire stacked PR chain (#2–#6) that
targets feature branches off this one.
…rements.txt farm_field_geo depends on base_geoengine, which isn't on the upstream OCA/geospatial 19.0 branch yet (PR #446 is open + green but unmerged). Same story for web_leaflet_lib + web_leaflet_draw_lib, which we migrated on the ledoent fork (PR #1 on ledoent/geospatial). Adds a top-level test-requirements.txt with git+https pins for each. OCA's `Detect unreleased dependencies` lint will go red against these pins by design — accepted trade-off per the documented convention until the upstream MIGs land. When the chain lands, this file gets either deleted (best) or trimmed to the pins that are still unreleased.
…tion Odoo 19 removed 'inline' from the allowed values of ir.actions.act_window.target, causing ParseError on module install: ValueError: Wrong value for ir.actions.act_window.target: 'inline' Default target (current) is what every other res.config.settings action uses, so just drop the line.
dnplkndll
added a commit
that referenced
this pull request
May 18, 2026
#1) * feat(farm_base): add farm.mixin AbstractModel for color/notes/mail.thread Eliminates ~12 lines × 8+ farm models. All SMB-tier models and existing farm modules can _inherit = ["farm.mixin"] to pick up the shared bundle in one line. * feat(farm_crop): catalog of farm crops with 18 seeded entries farm.crop is the canonical crop identity referenced by farm.field, farm.planting, and farm.harvest. Ships with 18 common US small-farm crops under noupdate=1 so farmers can edit freely. Fields: - name, latin_name, family (Solanaceae, Brassicaceae, etc. — useful for rotation) - category: vegetable/fruit/grain/legume/herb/cover/forage/flower/other - days_to_maturity (consumed by farm.planting._compute_expected_harvest_date) - image (auto-sized 128px variant for kanban) 5 tests. * feat(farm_field): fields/plots with multi-company isolation farm.field models a plot of land. Inherits farm.mixin (color/notes/mail.thread). Fields: - name, code (used on signage), farm_partner_id, company_id - acres (manual; farm_field_geo will compute from polygon) - crop_id (current crop), season_id, organic_certified (tracked) Multi-company: - _check_company_auto = True - ir.rule scopes [company_id IN env.company_ids] globally - security covered by test (user in company A blocked from company B's field) 6 tests including multi-company isolation. * feat(farm_planting): planting events with state machine + multi-company farm.planting records a (field, crop, date) tuple. State machine walks through planted → growing → harvested|failed. Expected harvest date auto-computes from crop.days_to_maturity (overrideable). Multi-company: company_id is related to field_id.company_id, store=True + index=True + precompute=True (NOT NULL at INSERT so ir.rule binds correctly). ir.rule scoping by company_id. field_id is check_company=True. 9 tests including precompute and date-constraint checks. * feat(farm_harvest): harvest events with auto-fill from planting farm.harvest logs quantity + UoM + date for each pick. Two flows: (1) from a planting — field/crop auto-fill via precompute=True compute, locked readonly in the form; (2) standalone — manual field/crop entry for retroactive records. Multi-company: company_id related to field.company_id, precompute=True. ir.rule scoping. check_company=True on field_id. Optional grade (A/B/C/compost) for tiered pricing downstream. 6 tests including stale field_id behavior when planting cleared. * fix: kanban templates for Odoo 19 Card system The Card template introduced in Odoo 17+ doesn't support the legacy wrappers (`oe_kanban_details`, `o_kanban_image_fill_left`) or the `highlight_color` attribute, and the `t-if="record.X.raw_value"` conditional pattern that worked in v18 raises an OwlError at mount time. Rewrite all four kanbans in the simplified Card style (mirrors farm_egg_production): drop wrapper divs, drop `highlight_color`, replace conditional t-if with bare `<field>` references that render empty when null. Verified against fresh 19.0 DB — 0 page errors, all records render. * fix(farm_qbo_connection): implement action_refresh_token referenced by form view The form view's header declared a `Refresh Token` button (visible when state ∈ {connected, expired}) calling `action_refresh_token`, but the model never shipped the method. Odoo's view validator caught it at install time: ParseError: while parsing farm_qbo_connection_views.xml:25 action_refresh_token is not a valid action on farm.qbo.connection Adds the method on the model and the underlying token-refresh round-trip on services/intuit_client.IntuitClient.refresh_access_token() — uses intuitlib.client.AuthClient.refresh() when the libs are installed, raises a clear UserError in stub mode. Two tests cover both paths: missing refresh token → UserError; mocked successful refresh → connection record updated with new access/refresh tokens + expiry. Unblocks CI on PR #1 and the entire stacked PR chain (#2–#6) that targets feature branches off this one. * fix(farm_quickbooks_io): drop deprecated target=inline on settings action Odoo 19 removed 'inline' from the allowed values of ir.actions.act_window.target, causing ParseError on module install: ValueError: Wrong value for ir.actions.act_window.target: 'inline' Default target (current) is what every other res.config.settings action uses, so just drop the line. * fix(farm_crop): inherit image.mixin to fix duplicate-label warning OCA's checklog step fails the CI workflow on any ERROR or WARNING in the Odoo log. PR #1's last red was: WARNING odoo.addons.base.models.ir_model: Two fields (image_128, image_1920) of farm.crop() have the same label: Image 1920. farm.crop declared `image_1920` and `image_128 = fields.Image(related= image_1920, ...)` directly. A related field inherits the source field's string by default, so both fields end up labeled "Image 1920" — Odoo flags the collision. Switch to inheriting `image.mixin` (the standard Odoo helper) which ships image_128/256/512/1024/1920 with properly differentiated labels. Drops the manual declarations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends
farm.fieldwith a PostGIS polygon column (geom, WGS84/4326) and auto-computesacresfrom the polygon area, reprojected to EPSG:5070 Conus Albers Equal Area — the projection NRCS and NASS use for lower-48 acreage. Without this module the base field's acreage is a manual decimal entry; with it, setting a boundary updates the number automatically while staying editable as a fallback (readonly=False + store=True).This is the MVP slice of the farm-geo implementation plan. It's the foundation for
farm_field_overlays,farm_observation,farm_water_source, and the v2 PWA mobile capture layer.Commits (review order)
feat(farm_field_geo): PostGIS polygon + auto-computed acreage— module scaffold (manifest, model inherit, form-view + geoengine-view inherit, four base tests, readme fragments)refactor(farm_field_geo): self-review fixes— second-pass cleanup: move geom widget to its own Boundary tab (full width), addgeom_field="geom"to the map view, extract a WKT helper in tests, drop a weak zero-acres assertion, add two stronger tests (compute-overrides-manual + deterministic-per-polygon), untangle USAGE wording, document scope + install requirementDepends on
feat(smb-tier): farm models (crop catalog + field + planting + harvest)Targets
feat/smb-tierbecause the basefarm.fieldmodel lives on that branch (not yet on19.0). When #1 merges, GitHub auto-retargets this PR to19.0and the diff collapses to just the new module.Upstream dependency forward-ports
OCA/geospatial 19.0 is mostly empty. Workspace
repos.yamlcomposes three sources:Each pin reverts to plain
oca 19.0as the upstream MIGs land. With all three in place, the Boundary tab'sgeo_edit_mapwidget renders Leaflet-Geoman vertex-edit controls — no longer read-only.Test coverage
Five tests in
tests/test_farm_field_geo.py:test_acres_manual_entry_persists_without_geomacresvalue sticks; compute does not zero ittest_acres_compute_from_polygontest_acres_compute_overrides_manual_entry_on_geom_setgeom→ compute wins on savetest_acres_recomputes_on_geom_changegeomfrom a tiny to a large polygon scalesacresaccordinglytest_acres_deterministic_for_identical_polygonWhat's deferred (deliberately)
farm_field_overlays. USDA CDL + NRCS SSURGO read-only WMS overlays. Next slice of the geo plan, separate PR.GeoMultiPolygoninstead ofGeoPolygon. MVP records each plot as its ownfarm.fieldrow; documented in DESCRIPTION.Screenshots
Not applicable in this PR —
farm.fieldlives on thefeat/smb-tierbase branch which hasn't merged into19.0yet, so the workspace can't actually installfarm_field_geoend-to-end until that lands. Screenshots will be captured in a follow-up comment once both this PR and #1 are installable on a review env.Test plan
invoke install -m farm_field_geo && invoke test farm_field_geogeomset, confirm the Boundary tab renders the polygon with Leaflet-Geoman edit controls andacresmatches the area-derived value