Skip to content

[IMP] base_geoengine: operator API for spatial domains + front fixes - #13

Open
leNeo wants to merge 4 commits into
weinni2000:20.0-mig-base_geoenginefrom
leNeo:improve-20-domain-operators
Open

leNeo wants to merge 4 commits into
weinni2000:20.0-mig-base_geoenginefrom
leNeo:improve-20-domain-operators

Conversation

@leNeo

@leNeo leNeo commented Nov 6, 2026 •

Copy link
Copy Markdown

Proposed on top of OCA#489 (head 8e99ffa):

  • Replace the monkey patches of DomainCondition / Field with operator_optimization + Domain.custom. Relational paths are resolved by core; access checks are kept.
  • Fix geo_equal returning nothing for identical geometries (the SRID was missing); invalid indirect references now raise ValueError.
  • Fix "Invalid domain" shown for valid indirect geo conditions in the vector layer form.
  • Fix the rendering of all layers aborting when one colored layer has no value.
  • Six new regression tests; with these, the expanded suite fails on the PR head (2 failures, 1 error) and passes here (0 failures).

Tested on Odoo 20 / PostgreSQL 17 / PostGIS, and in the browser (domain editor, map). Upstream CI still to run.

🤖 Generated with Claude Code

Summary by Sourcery

Modernize spatial domain handling and stabilize geoengine domain evaluation and map rendering.

Bug Fixes:

  • Fix spatial equality queries, invalid indirect references, valid indirect geo-domain validation, and layer rendering when colored attributes have no usable values.

Enhancements:

  • Replace geospatial ORM monkey patches with Odoo's operator optimization and custom domain APIs while preserving relational path resolution and access checks.

Tests:

  • Add regression coverage for SRID-preserving equality, invalid references, non-spatial operands, relational paths, active-domain behavior, and related-model access control.

weinni2000 and others added 3 commits November 1, 2026 09:30
Assisted-by: Claude Code (claude-opus-5-5)
…tor API

Register the spatial operators with `operator_optimization` and convert
them to `Domain.custom` at full optimization, replacing the monkey
patches of `DomainCondition._optimize_step`, `DomainCondition._to_sql`
and `Field._condition_to_sql`. Odoo then resolves relational paths,
inherited and searchable fields before the spatial SQL is generated.

Direct geometry comparisons now carry the SRID of the field, which fixes
`geo_equal` returning no match for an identical geometry. Invalid
indirect references (empty, unknown model or field, non-string key)
raise a `ValueError`. Read access on the related model and on the
referenced fields is still checked, together with `_access_domain`.

Add six regression tests: direct equality and SRID, invalid references,
spatial operator on a non-geo field, relational path, archived records
and `Domain` sub-domains, and indirect search without read access.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The core domain field reports the python dict of an indirect geo
condition ({"<model>.<geo field>": <domain>}) as a non-literal, so the
vector layer form showed "Invalid domain" for a valid domain. Evaluate
such domains directly for geoengine.vector.layer.

A colored or proportional layer without any value (e.g. its domain
matches no record) made geostats throw "You should first enter a
serie!", which aborted the rendering of all the layers. Such a layer now
gets the default style.

Also remove a leftover console.log in the colored layer style.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

API

Register spatial operators through Odoo’s optimization API and compile them into custom domains at full optimization.

  • base_geoengine/domains.py L1-18

Implementation

Implement spatial SQL generation with field-SRID geometry comparisons, validated indirect references, and related-model access and record-rule checks.

  • base_geoengine/expressions.py L3-7, L30-94 (+3 small edits)

UI

Evaluate valid indirect spatial domains in the vector-layer editor and fall back to default styling when colored or proportional layers have no usable values.

  • base_geoengine/static/src/js/views/geoengine/geoengine_renderer/geoengine_renderer.esm.js L5 (removed lines), L1118-1129, L1205 (removed lines)
  • base_geoengine/static/src/js/widgets/domain_selector_geo_field/domain_selector_active_ids/domain_selector_active_ids.esm.js L7, L29-30, L123-139

Tests

Add regression coverage and fixture fields for spatial equality and SRID, invalid operators and references, relational paths, active filtering, and related-model access.

  • base_geoengine/tests/models.py L25, L38
  • base_geoengine/tests/test_model.py L7-8, L519-592

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="base_geoengine/static/src/js/views/geoengine/geoengine_renderer/geoengine_renderer.esm.js" line_range="1123" />
<code_context>
+        // instead of aborting the rendering of all the layers.
+        if (
+            ["colored", "proportion"].includes(cfg.geo_repr) &&
+            !this.extractLayerValues(cfg, data).length
+        ) {
+            return this.styleVectorLayerDefault(cfg);
</code_context>
<issue_to_address>
**Empty values still reach classification**

When matching records exist but all have an unset attribute value, when matching records exist but their attribute values are all unset, `extractLayerValues` returns an array with entries, so this guard does not select the default style and the colored or proportional classifiers still receive values with no usable data; the layer can still render incorrectly or fail.

Filter out unset values before classification and select the default style when no usable values remain.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and indirect spatial searches build an EXISTS query over a related model, so a mistake in the compiled read-access domain could let users infer matches involving records they cannot read. That inference cannot be undone by reverting, though the change does not appear to establish a new access policy or trust boundary.

Blocking findings: base_geoengine/static/src/js/views/geoengine/geoengine_renderer/geoengine_renderer.esm.js:1123


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Also fall back to the default style when records exist but the
attribute of a colored or proportional layer is unset on all of them,
not only when no record matches.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@weinni2000
weinni2000 force-pushed the 20.0-mig-base_geoengine branch 3 times, most recently from 44a8119 to f54f4f9 Compare November 10, 2026 08:34
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