跳至內容
選單
此問題已被標幟
2194 瀏覽次數

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?


頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
7月 25
600
1
2月 25
1304
0
9月 23
2254
2
6月 23
4088
1
8月 22
12840