Skip to Content
Menu
This question has been flagged
1 Reply
17931 Views

Hi everyone,

I try to create my search view, inherit from view_message search, the original view is:

<record model="ir.ui.view" id="view_message_search">

            <field name="name">mail.message.search</field>

            <field name="model">mail.message</field>

            <field name="priority">25</field>

            <field name="arch" type="xml">

                <search string="Messages Search">

                    <field name="body" string="Content" filter_domain="['|', ('subject', 'ilike', self), ('body', 'ilike', self)]" />

                    <field name="subject"/>

                    <field name="message_type"/>

                    <field name="author_id"/>

                    <field name="partner_ids"/>

                    <field name="model"/>

                    <field name="res_id"/>

                    <field name="parent_id"/>

                    <filter string="Need Action"

                            name="message_needaction" help="Unread messages"

                            domain="[('needaction', '=', True)]"/>

                    <separator/>

                    <filter string="Has attachments"

                            name="attachments"

                            domain="[('attachment_ids', '!=', False)]"/>

                </search>

            </field>

        </record>

And my custom view is:

<record model="ir.ui.view" id="custom_view_message_search">

            <field name="name">mail_custom.message.search</field>

            <field name="model">mail.message</field>

            <field name="inherit_id" ref="mail.view_message_search"/>

            <field name="arch" type="xml">

                <field name="body" position="after">

                    <separator/>

                    <field name="subtype_id"/>

                </field>

            </field>

        </record>

Now, the subtype_id is included, but how can I change the filter_domain in the base view? Now, it's only search by 'subject' and 'body' field, I'd like to add the 'subtype_id' to filter_domain.

Thank you

Avatar
Discard

res.partner.select
res.partner











Best Answer

You can replace the filter using xpath

<xpath expr="//filter[@name='filter_name']" position="replace">
<filter string="Any string"
domain="[('state','=','installed')]"/>
</xpath>

Here you can set any domain you need

Avatar
Discard
Author

Thank you @Mohammed Amal