MerginMaps / MerginMaps/mobile
current_parent_value() in a Value Relation
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 388
- Forks
- 87
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 20
Description
Description
current_parent_value() does not work in a Value Relation filter expression in the mobile app. The dropdown comes back empty.
Internal support ticket: https://support.lutraconsulting.co.uk/odoo/all-tickets/16951
Environment
Production
Application (+ app version, build, operating system)
Latest app, platform-independent
Steps to reproduce
- GeoPackage with three layers:
site(point) —site_id(text),habitat_code(text)observation(table) —site_id(text),species_code(text),note(text)species(table) —habitat_code(text),species_code(text),species_name(text), populated for at least two habitats
- 1:N relation
site.site_id(referenced) ->observation.site_id(referencing). - On
siteadd a Relation widget for that relation to the drag-and-drop form. - On
observation.species_codeset widget Value Relation -> layerspecies, Keyspecies_code, Valuespecies_name, filter:
"habitat_code" = current_parent_value('habitat_code')
5a. Sync, open on mobile, create asitepoint, sethabitat_code, create a linkedobservationrow, save.
6a. Reopen the point and it's linked observation, hitedit record, try to open the species dropdown for the observation
5b. In plugin create asitepoint, sethabitat_code, create a linkedobservationrow, save.
6b. Reopen the point and its linked observation, hitedit record, choose a species. Sync.
7b. Open and sync the project on mobile. Open the point and its linked observation with the species chosen, hitedit record, and type something in thenotefield
Actual results
a, Dropdown is empty. Removing the filter shows all species.
b, Filled dropdown gets erased
Expected results
a, Dropdown lists only the species of the plant community selected on the parent feature, as it does in QGIS desktop.
b, When editing one field, the other should not change when it's not connected.
Extra debugging info
The app never builds a parent form scope for value-relation queries.
AttributeController itself does build the scope, which is why current_parent_value() works in virtual fields, default values, visibility and constraint expressions but not in the value-relation widget filter.
Parents do not work for these:
- Dropdown list query
- Display-text lookup
- Default values
AttributeController itself does build the scope (app/attributes/attributecontroller.cpp:886-889), which is why current_parent_value() works in virtual fields, default values, visibility and constraint expressions but not in the value-relation widget filter.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with app/attributes/attributecontroller.cpp:886-889, then trace how the Value Relation widget builds its dropdown query, display-text lookup, and default-value handling. Reproduce the issue with the three-layer GeoPackage and the listed parent filter on mobile and in the plugin. Done means current_parent_value() works for these parent-dependent operations and editing an unrelated field no longer erases the selected value.
Written by the indexing model from the issue text.
Assessment
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100