MerginMaps / MerginMaps/mobile

current_parent_value() in a Value Relation

Open
#4,695 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug relations
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

  1. 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
  2. 1:N relation site.site_id (referenced) -> observation.site_id (referencing).
  3. On site add a Relation widget for that relation to the drag-and-drop form.
  4. On observation.species_code set widget Value Relation -> layer species, Key species_code, Value species_name, filter:
    "habitat_code" = current_parent_value('habitat_code')
    5a. Sync, open on mobile, create a site point, set habitat_code, create a linked observation row, save.
    6a. Reopen the point and it's linked observation, hit edit record, try to open the species dropdown for the observation
    5b. In plugin create a site point, set habitat_code, create a linked observation row, save.
    6b. Reopen the point and its linked observation, hit edit record, choose a species. Sync.
    7b. Open and sync the project on mobile. Open the point and its linked observation with the species chosen, hit edit record, and type something in the note field

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:

  1. Dropdown list query
  2. Display-text lookup
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.