Search code examples
odoo-10odoo-view

Customize Search Window Odoo 10


I'm busy creating a custom module for Odoo 10. Part of it is to make sure Products are displayed with a default Group By in the Search Window. I can't seem to find the view/template where that could be organised. Has anybody an idea? Thanks in advance.


Solution

  • Say you want to group by categ_id. Then all you need to do is add a new filter like this:

    <filter name="groupby_categ_id"
    string="Internal Category"
    context="{'group_by': 'categ_id'}"/>
    

    And you will have to add this filter by default with the action context:

    <field name="context">
    {'search_default_groupby_categ_id': 1}
    </field>
    

    edit:

    You can also pass this as a context of a field as follows:

    <field name="product_tmpl_id" 
    context={'search_default_groupby_categ_id': 1}
    />
    

    And then when clicking on Search more the filter will be on by default.