<?xml version="1.0"?>
<openerp>
    <data>

        <record id="view_crm_lead2opportunity_partner" model="ir.ui.view">
            <field name="name">crm.lead2opportunity.partner.form</field>
            <field name="model">crm.lead2opportunity.partner</field>
            <field name="arch" type="xml">
                <form string="Convert to Opportunity" version="7.0">
                    <group name="name">
                        <field name="name" class="oe_inline"/>
                    </group>
                    <group string="Opportunities">
                        <field name="opportunity_ids" attrs="{'invisible': [('name', '!=', 'merge')]}" nolabel="1">
                            <tree>
                                <field name="create_date"/>
                                <field name="name"/>
                                <field name="type"/>
                                <field name="contact_name"/>
                                <field name="country_id" invisible="context.get('invisible_country', True)"/>
                                <field name="email_from"/>
                                <field name="phone"/>
                                <field name="stage_id"/>
                                <field name="user_id"/>
                                <field name="section_id"/>
                            </tree>
                        </field>
                    </group>
                    <group name="action" attrs="{'invisible': [('name', '!=', 'convert')]}">
                        <field name="action" on_change="onchange_action(action, context)" class="oe_inline"/>
                        <field name="partner_id"
                            attrs="{'required': [('action', '=', 'exist')], 'invisible':[('action','!=','exist')]}"
                            class="oe_inline"/>
                    </group>
                    <footer>
                        <button name="action_apply" string="Create Opportunity" type="object" class="oe_highlight"/>
                        or
                        <button string="Cancel" class="oe_link" special="cancel"/>
                    </footer>
                </form>
            </field>
        </record>

        <record id="view_crm_lead2opportunity_partner_mass" model="ir.ui.view">
            <field name="name">crm.lead2opportunity.partner.mass.form</field>
            <field name="model">crm.lead2opportunity.partner.mass</field>
            <field name="arch" type="xml">
                <form string="Convert to Opportunity" version="7.0">
                    <separator string="Conversion Options"/>
                    <group>
                        <field name="name" class="oe_inline"/>
                    </group>
                    <group attrs="{'invisible': [('name', '!=', 'convert')]}">
                        <field name="action" class="oe_inline"/>
                        <field name="partner_id"
                            attrs="{'required': [('action', '=', 'exist')], 'invisible':[('action','!=','exist')]}"
                            class="oe_inline"/>
                    </group>
                    <group string="Select Opportunities" attrs="{'invisible': [('name', '!=', 'merge')]}">
                        <field name="opportunity_ids" colspan="4" nolabel="1" attrs="{'invisible': [('name', '=', 'convert')]}">
                            <tree>
                                <field name="create_date"/>
                                <field name="name"/>
                                <field name="type"/>
                                <field name="contact_name"/>
                                <field name="country_id" invisible="context.get('invisible_country', True)"/>
                                <field name="email_from"/>
                                <field name="phone"/>
                                <field name="stage_id"/>
                                <field name="user_id"/>
                                <field name="section_id"/>
                            </tree>
                        </field>
                    </group>

                    <group string="Assign opportunities to" attrs="{'invisible': [('name', '=', '')]}">
                        <field name="section_id"/>
                        <field name="user_ids" widget="many2many_tags"/>
                    </group>

                    <footer>
                        <button name="mass_convert" string="Convert to Opportunities" type="object" class="oe_highlight"/>
                        or
                        <button string="Cancel" class="oe_link" special="cancel"/>
                    </footer>
                </form>
            </field>
        </record>

        <record id="action_crm_lead2opportunity_partner" model="ir.actions.act_window">
            <field name="name">Convert to opportunity</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">crm.lead2opportunity.partner</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="view_crm_lead2opportunity_partner"/>
            <field name="target">new</field>
        </record>

        <act_window id="action_crm_send_mass_convert"
            multi="True"
            key2="client_action_multi" name="Convert to opportunities"
            res_model="crm.lead2opportunity.partner.mass" src_model="crm.lead"
            view_mode="form" target="new" view_type="form"
            context="{'mass_convert' : True}"
            view_id="view_crm_lead2opportunity_partner_mass"/>

    </data>
</openerp>
