+1 vote

I created a favorite filter in XML and I want to integrate it by default to an XML view, here is the filter code:

<record id="myfavorite_filter_catering" model="ir.filters">
    <field name="name">Catering - End of year break</field>
    <field name="model_id">ecole.partner.school</field>
    <field name="user_id" eval="False"/>
    <field name="is_default">False</field>
    <field name="domain">[('period_school_year','=',True),('default_school_year','=',False),('half_pension_previous','=',True),('half_pension','=',False)]</field>
    <field name="context">{'group_by': ['school_name_id', 'school_level_id']}</field>

Is it possible ? and how to write it?

Thank you

in Back-end by (10.5k points) | 452 views

1 Answer

0 votes

hi, Khayreddine,
You can do like this:

In xml code: 

<!-- search view -->

      <filter string="My favorite filter" name="favorite_filter" domain="[('field_name', 'operator', value)]"/>

And Into views action, you have to pass the context like this:

<record id="xml_id" model="ir.actions.act_window">
     <field name="context">{'search_default_favorite_filter': 1}</field>

Enjoy Odoo ;)

by (3.7k points)
edited by
204 questions
180 answers
268,142 users