Odoo Help

Welcome!

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.

0

Set default filter from button

By
Sebastian Orzechowski
on 3/25/14, 8:56 AM 2,426 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,}"/>

0

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>

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
0
Weste
On 3/25/14, 12:06 PM

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.

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

0 follower(s)

Stats

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