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

    <!--
    ================================================================
    Marketing Activity Inherited View - mailchimp
    ================================================================
    -->

    <record model="ir.ui.view" id="view_marketing_campaign_activity_form_inherit">
        <field name="name">marketing.campaign.activity.form.inherit</field>
        <field name="model">marketing.campaign.activity</field>
        <field name="type">form</field>
        <field name="inherit_id" ref="marketing_campaign.view_marketing_campaign_activity_form"/>
        <field name="arch" type="xml">
            <xpath expr='//field[@name="type"]/following-sibling::group' position='inside'>
                <group colspan="2" attrs="{'invisible':[('type','!=','mailchimp')]}">
                    <field name="mailchimp_account_id" attrs="{'required':[('type','=','mailchimp')]}" domain="[('state','=','approved')]" on_change="onchange_mailchimp(mailchimp_account_id)"/>
                    <field name="mailchimp_list" attrs="{'required':[('type','=','mailchimp')]}" on_change="onchange_mailchimp_list(mailchimp_account_id,mailchimp_list)"/>
                </group>
            </xpath>
        </field>
    </record>


    <!--
    ================================================================
    Mailchimp Account
    ================================================================
    -->

    <menuitem name="Tools" id="base.menu_tools" icon="STOCK_PREFERENCES" sequence="28"/>
    <menuitem name="Mailchimp" id="menu_action_mailchimp" parent="base.menu_emails" />

    <record model="ir.ui.view" id="view_mailchimp_account_tree">
        <field name="name">mailchimp.account.tree</field>
        <field name="model">mailchimp.account</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree colors="blue:state in ('draft');black:state in ('approved');gray:state in ('cancelled')" string="Accounts">
                <field name="name"/>
                <field name="username" />
                <field name="data_center"/>
                <field name="state"/>
            </tree>
        </field>
    </record>

    <record model="ir.ui.view" id="view_mailchimp_account_form">
        <field name="name">mailchimp.account.form</field>
        <field name="model">mailchimp.account</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Account">
                <field name="name" select="1"/>
                <newline/>
                <field name="username" select="1"/>
                <field name="password" select="1" password="True"/>
                <field name="apikey" />
                <field name="data_center" required="1"/>
                <separator string="Status" colspan="4"/>
                <group col="13" colspan="4">
                    <field name="state" nolabel="1"/>
                    <button name="button_approve" string="Approve" states="draft" type="object"/>
                    <button name="button_cancel" string="Cancel" states="draft,approved" type="object"/>
                </group>
            </form>
        </field>
    </record>

    <record model="ir.actions.act_window" id="action_mailchimp_account">
        <field name="name">Mailchimp Accounts</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">mailchimp.account</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="view_id" ref="view_mailchimp_account_tree"/>
    </record>

    <menuitem id="menu_action_mailchimp_account" parent="menu_action_mailchimp" action="action_mailchimp_account" sequence="40"/>

    </data>
</openerp>
