Skip to content

[16.0][IMP] fieldservice_geoengie: Fix vector Layer related Errors#1453

Open
anusriNPS wants to merge 1 commit intoOCA:16.0from
PyTech-SRL:16.0-fix-geoview
Open

[16.0][IMP] fieldservice_geoengie: Fix vector Layer related Errors#1453
anusriNPS wants to merge 1 commit intoOCA:16.0from
PyTech-SRL:16.0-fix-geoview

Conversation

@anusriNPS
Copy link
Contributor

@anusriNPS anusriNPS commented Oct 8, 2025

Depends on base_geoengine PR #417
Domain for "attribute_field_id" is filtered based on "classification" field selection in vector layer, which helps to avoid JS error seen as "fsm.order" and "fsm.location" related fields are not validated based on "NUM_ATT" types. base_geoengine_validation.

Notifying user to define selected field from attribute_field_id of supported type in geoengine view which avoids below JS error observed:
Screenshot from 2025-10-08 17-09-18

Notifying users when a field of supported type from attribute_field_id is not suitable to use for classification type "custom" which avoids below observed JS Error:
image

As fieldservice_geoengine omits validation for custom classification related to "type" check on field selected in "attribute_field_id", when user selects fields of type "date" with "custom", below JS error observed:
image

@OCA-git-bot
Copy link
Contributor

Hi @wolfhall, @max3903,
some modules you are maintaining are being modified, check this out!

@anusriNPS anusriNPS changed the title [16.0][IMP] fieldservice_geoengie: Fix vector Layer related Errors [16.0][IMP] fieldservice_geoengie: Fix vector Layer related Error Oct 8, 2025
@anusriNPS anusriNPS changed the title [16.0][IMP] fieldservice_geoengie: Fix vector Layer related Error [16.0][IMP] fieldservice_geoengie: Fix vector Layer related Errors Oct 8, 2025
@anusriNPS anusriNPS marked this pull request as draft October 13, 2025 08:34
@anusriNPS
Copy link
Contributor Author

Notifying user to define selected field in geoengine view from attribute_field_id whose field is of supported type:
Screenshot from 2025-10-13 08-49-45

Notifying user when selected field in "attribute_field_id" is of supported type but not suitable for interval/custom range. Example: "color" field which is of "integer" type in "fsm.location" but could not generate interval/custom range, if not suppressed JS error is seen.

Interval range:
image
Custom range:
image

For custom classification with field type such as "date", based on this PR it suppress JS error but view displayed for "custom" will not be the expected view. This is because user needs to use proper field for selected field type to display customized view. Below is the view when "request_early" is selected from "attribute_field_id" for "custom".

image

@anusriNPS anusriNPS marked this pull request as ready for review October 14, 2025 06:45
Copy link
Contributor

@HekkiMelody HekkiMelody left a comment

Choose a reason for hiding this comment

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

Code review, LGTM

Comment on lines +10 to +21
SUPPORTED_ATT = [
"float",
"integer",
"integer_big",
"related",
"function",
"date",
"datetime",
"char",
"text",
"selection",
]
Copy link
Contributor

Choose a reason for hiding this comment

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

chore (non-blocking): I see these elsewhere in the code as well, but I suspect they may have remained from previous versions, as I cannot find values of ttype matching some of these.

On a fresh odoo installation, opening a shell and inspecting env["ir.model.fields"]._fields["ttype"].selection I get the following fields

['binary', 'boolean', 'char', 'date', 'datetime', 'float', 'html', 'integer', 'json', 'many2many', 'many2one', 'many2one_reference', 'monetary', 'one2many', 'properties', 'properties_definition', 'reference', 'selection', 'text', 'serialized']

Copy link
Contributor Author

@anusriNPS anusriNPS Oct 22, 2025

Choose a reason for hiding this comment

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

env["ir.model.fields"]._fields["ttype"].selection - list all available ttype values.

fieldservice_geoengine supports only fields based on SUPPORTED_ATT and NUM_ATT which is used in domain to filter from ttype values.

ttype will not match the fields of supported_att and num_att variables and it should list all available types. ttype list seems right and this is my understanding. Please correct me, if my views differ from your thoughts.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I probably wasn't very clear. I didn't mean to imply that fields should be added to SUPPORTED_ATT, but rather that some may be removed (maybe?), like integer_big, related and function.

Either way, non-blocking.

Comment on lines +52 to +56
rec.geo_repr == "colored"
and (
rec.classification != "unique"
and rec.classification != "custom"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (non-blocking): readability

Suggested change
rec.geo_repr == "colored"
and (
rec.classification != "unique"
and rec.classification != "custom"
)
rec.geo_repr == "colored"
and rec.classification not in ("unique", "custom")

I would also add brackets for clarity

                    (rec.geo_repr == "colored"
                    and rec.classification not in ("unique", "custom"))
                    or ....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated as suggested

   Notifying user to define selected attribute_field_id of
supported type from vector layer in infoBox template to avoid
JS error. Addressed JS Error when supported data type even
defined in geoengine view as well.
   When a field from attribute_field_id values selected from
vector layer is not suitable for "custom" classification, it
is notified to the user to avoid JS Error.Similarly for interval
classification is also taken care.
   Domain for attribute_field_id is filter based on classification
selection in vector layer to avoid JS Error.
@github-actions
Copy link

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Feb 22, 2026
@HekkiMelody
Copy link
Contributor

HekkiMelody commented Feb 23, 2026

@OCA/geospatial-maintainers Hello, could you take a look? Thanks
Wrong ping, sorry, I meant @OCA/field-service-maintainers

@hparfr
Copy link
Contributor

hparfr commented Feb 26, 2026

Does it need OCA/geospatial#417 to be merged first ?

@HekkiMelody
Copy link
Contributor

Does it need OCA/geospatial#417 to be merged first ?

yes, actually, it does

@github-actions github-actions bot removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Mar 1, 2026
Copy link
Contributor

@marcos-mendez marcos-mendez left a comment

Choose a reason for hiding this comment

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

Automated Review -- Tests Failed

1. Root Cause

The test failure is caused by a database connection error during the Odoo startup, not directly related to the changes in the PR. However, the new oca_dependencies.txt file references a nonexistent or broken geospatial dependency, which likely leads to a failure in module loading or dependency resolution.

2. Suggested Fix

  • File: fieldservice_geoengine/oca_dependencies.txt
  • Issue: The dependency URL and commit hash are invalid or unreachable.
  • Fix: Either:
    • Correct the dependency URL or commit hash to a valid reference.
    • Remove the dependency if it's not required for the current changes.
    • Confirm that the referenced PR (refs/pull/417/head) is stable and accessible.

Line: 1
Current: geospatial https://github.com/OCA/geospatial refs/pull/417/head 9825f67d128918294b67b74d324d1e6d3259399b
Suggestion: Update to a working commit or remove if unnecessary.


3. Additional Code Issues

a. Potential crash in JS code

  • File: fieldservice_geoengine/static/src/js/views/geoengine/geoengine_renderer/geoengine_renderer.esm.js
  • Issue: In styleVectorLayer method, the try...catch block silently swallows errors and returns early without logging or notifying the user.
  • Fix: Log the error or provide a more informative fallback.

Lines: 113–118
Suggestion: Add console.error(error) or a more user-facing error notification.

b. Inconsistent handling of attribute_field_id_domain

  • File: fieldservice_geoengine/models/vector_layer.py
  • Issue: The _compute_attribute_field_id_domain method builds a domain based on conditions, but it does not validate that rec.geo_field_id.model_id.model is a valid model.
  • Fix: Add a check or error handling to ensure geo_field_id.model_id.model is valid before using it in a domain.

Lines: 48–56
Suggestion: Add a try-except or validation for rec.geo_field_id.model_id.model.


4. Test Improvements

a. Add test for oca_dependencies.txt

  • Type: SavepointCase or TransactionCase
  • Test Case: Ensure the module loads without errors when oca_dependencies.txt is present and valid.
  • Tags: @odoo-test, @runboat-ready

b. Test attribute_field_id_domain computation

  • Type: TransactionCase
  • Test Case: Create a GeoVectorLayer record and assert that attribute_field_id_domain is correctly computed based on geo_repr and classification.
  • Tags: @odoo-test, @geoengine

c. Test JS error handling in geoengine_renderer.esm.js

  • Type: SavepointCase or HttpCase
  • Test Case: Simulate an invalid label_text to ensure the JS code doesn't crash and logs appropriately.
  • Tags: @odoo-test, @frontend, @geoengine

d. Test checkAttributeFieldUsage and getClass methods

  • Type: TransactionCase or SavepointCase
  • Test Case: Test edge cases in getClass like null, undefined, or invalid values.
  • Tags: @odoo-test, @geoengine

Summary

  • The test failure is likely due to a broken dependency, not the core logic.
  • The JS code has a silent error handler that should be improved.
  • The domain computation logic should include validation for model references.
  • Add unit tests for domain logic, JS error handling, and frontend behavior.

⏰ PR Aging Alert

This PR by @anusriNPS has been open for 158 days (5 months).

Every ignored PR is a contributor who might not come back. Review time matters. (OCA Aging Report)


Reciprocal Review Request

Hi everyone! I found some test failures on this PR and left detailed feedback above. I am happy to discuss or help debug. In the meantime, if any of you get a chance, I would appreciate a look at my open PR(s):

My open PRs across OCA:

Reviewing each other's work helps the whole community move forward. Thank you!


Environment via OCA Neural Reviewer: Minikube + K8s Job + oca-ci/py3.10-odoo16.0 | Odoo 16.0
Automated review by OCA Neural Reviewer + qwen3-coder:30b

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.

5 participants