Skip to content

current_parent_value() in a Value Relation #4695

Description

@harminius

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPRIMARY CATEGORYrelationsissues regarding form relations

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions