Odoo Help


Set default filter from button

Sebastian Orzechowski
on 3/25/14, 8:56 AM 3,390 views

I want to create new button in customer view, redirect no messages view. I want set filter on the list which is show messages send to customer or customer is author. How can i create button with this OR filtering? This is my code, but it`s set AND relation .

<button type="action" string="Messages" attrs="{'invisible': [('customer', '=', False)]}" name="%(mail.message)d" context="{'search_default_partner_ids': name, 'search_default_author_id': active_id,}"/>


Thanks Weste. Domain set in button doesn't work. I managed to solve this problem by create a button and the action. Here is the code.

 <button type="action" string="Messages" attrs="{'invisible': [('customer', '=', False)]}" 

<record id="mail_message_partner" model="ir.actions.act_window">
        <field name="name">Messages</field>
        <field name="src_model">res.partner</field>
        <field name="res_model">mail.message</field>
        <field name="view_mode">tree,form</field>
        <field name="view_id" ref="mail.view_message_tree"/>
        <field name="search_view_id" ref="mail.view_message_search"/>
        <field name="context">{'partner_ids': active_id}</field>
        <field name="domain">['|', ('author_id', '=', active_id) ,('notified_partner_ids', '=', active_id)]</field>

I think your first solution (context in button) will work too, if your mail.message search view has a field for notified_partner_ids and author_id.

René Schuster
on 3/26/14, 8:00 AM
On 3/25/14, 12:06 PM

Maybe you can put a domain instead of a context:


with the correct field names, it should work. The '|' means OR.

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

0 follower(s)


Asked: 3/25/14, 8:56 AM
Seen: 3390 times
Last updated: 3/16/15, 8:10 AM