Odoo Help


Search fields clobbering later ones?

Ben Finney
on 3/25/15, 5:06 AM 768 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?

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 3/25/15, 5:06 AM
Seen: 768 times
Last updated: 3/25/15, 5:06 AM