Skip to Content
Menu
This question has been flagged
2180 Views

When creating a custom `<search>` element, the order of `<field>` elements changes which fields are active for the search. What are the precedence rules, where are they documented?

Example, with a model `vetclinic.animal` that has `name` as a `char` field, and `class_id` and `breed_id` as `many2one` fields:

    <search string="Animal">

        <field name="class_id" />

        <field name="breed_id" />

        <field name="name" />

    </search><!-- Animal -->

That will work as expected: the search box will present options to search on any of the `class`, `breed`, and `name` fields.

If the order is different:

    <search string="Animal">

         <field name="name" /><!-- Want to have this field listed first. -->

         <field name="class_id" />

        <field name="breed_id" />

    </search><!-- Animal -->

Now, unexpectedly, the search box omits the options to search by `class` or `breed`; only `name` is allowed.

Why does this happen? What are the rules for the difference in behaviour? Can I have the order of fields as I want, without losing some of them from the search?


Avatar
Discard
Related Posts Replies Views Activity
1
Jul 25
573
1
Feb 25
1281
0
Sep 23
2236
2
Jun 23
4067
1
Aug 22
12811