Odoo Help


This community 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.


Search fields clobbering later ones?

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


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