<?xml version="1.0" ?>
<openerp>
    <data>
        <record model="ir.ui.view" id="res_partner_opt_out_form">
            <field name="name">res.partner.opt_out.form</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form"/>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='active']" position="after">
                    <field name="opt_out"/>
                </xpath>
            </field>
        </record>

       <record model="ir.ui.view" id="res_partner_opt_out_search">
            <field name="name">res.partner.opt_out.search</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_res_partner_filter"/>
            <field name="arch" type="xml">
                    <filter string="Suppliers" position="after">
                        <separator />
                        <filter string="Available for mass mailing"
                                name='not_opt_out' domain="[('opt_out', '=', False)]"
                                help="Partners that did not ask not to be included in mass mailing campaigns" />
                    </filter>
            </field>
        </record>

        <!--Definition of an email template with an empty body that will be used in partner mailing. Used to give a
            basis for email recipients, name and to ease the definition of a further elaborated template. -->
        <record id="email_template_partner" model="email.template">
            <field name="name">Partner Mass Mail</field>
            <field name="model_id" ref="base.model_res_partner"/>
            <field name="auto_delete" eval="True"/>
            <field name="partner_to">${object.id}</field>
        </record>

        <!--  Replace the default mass-mailing wizard in base with the composition wizard -->
        <act_window name="Partner Mass Mailing"
                res_model="mail.compose.message"
                src_model="res.partner"
                view_mode="form"
                multi="True"
                target="new"
                key2="client_action_multi"
                id="base.action_partner_mass_mail"
                context="{
                            'default_composition_mode': 'mass_mail',
                            'default_partner_to': '${object.id or \'\'}',
                            'default_use_template': True,
                            'default_template_id': ref('email_template_partner'),
                        }"/>

        <record id="email_template_partner" model="email.template">
            <field name="ref_ir_act_window" ref="base.action_partner_mass_mail"/>
        </record>

    </data>
</openerp>
