This question has been flagged
2 Replies
9202 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,}"/>

Avatar
Discard
Best Answer

Maybe you can put a domain instead of a context:

domain="['|',('author','=','active_id'),('send_to','=','active_id')]"

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

Avatar
Discard
Author Best Answer

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)]}" 
                    name="%(mail_message_partner)d"/>

<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>
    </record>
Avatar
Discard

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.