<?xml version="1.0"?>
<openerp>
    <data>
    <record id="view_campaign_analysis_tree" model="ir.ui.view">
        <field name="name">campaign.analysis.tree</field>
        <field name="model">campaign.analysis</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Marketing Reports">
                <field name="year" invisible="1"/>
                <field name="month" invisible="1"/>
                <field name="day" invisible="1"/>
                <field name="date" invisible="1"/>
                <field name="state" invisible="1"/>
                <field name="campaign_id" invisible="1"/>
                <field name="activity_id" invisible="1"/>
                <field name="segment_id" invisible="1"/>
                <field name="partner_id" invisible="1"/>
                <field name="country_id" invisible="1"/>
                <field name="res_id" invisible="1"/>
                <field name="count"/>
                <field name="total_cost" string="Cost"/><!-- sum="Cost"/-->
                <field name="revenue"/>
            </tree>
        </field>
    </record>

    <record id="view_campaign_analysis_search" model="ir.ui.view">
        <field name="name">campaign.analysis.search</field>
        <field name="model">campaign.analysis</field>
        <field name="type">search</field>
        <field name="arch" type="xml">
            <search string="Campaign Analysis">
                   <group>
                    <filter icon="terp-go-year"
                            string="This Year"
                            domain="[('year','=',time.strftime('%%Y'))]"/>
                    <filter icon="terp-go-month"
                            string="This Month"
                            domain="[('month','=',time.strftime('%%m'))]"/>
                    <filter icon="terp-go-today"
                            string="Today"
                            domain="[('date','=',time.strftime('%%Y/%%m/%%d'))]"/>
                    <separator orientation="vertical"/>
                    <filter icon="terp-gtk-go-back-rtl"
                            string="To Do"
                            domain="[('state','=','todo')]"/>
                    <filter icon="terp-dialog-close"
                            string="Done"
                            domain="[('state','=','done')]"/>
                    <filter icon="terp-emblem-important"
                            string="Exceptions"
                            domain="[('state','=','exception')]"/>
                    <separator orientation="vertical"/>
                    <field name="campaign_id"/>
                    <field name="activity_id"/>
                    <field name="segment_id"/>
                    <field name="partner_id"/>
                    <field name="country_id"/>
                </group>
                <newline/>
                <group expand="0" string="Group By..." colspan="10" col="12">
                    <filter string="Campaign" name="Campaign" icon="terp-gtk-jump-to-rtl" context="{'group_by':'campaign_id'}" />
                    <filter string="Segment" name ="Segment" icon="terp-stock_symbol-selection" context="{'group_by':'segment_id'}" />
                    <filter string="Activity" name ="activity" icon="terp-stock_align_left_24" context="{'group_by':'activity_id'}" />
                    <filter string="Resource" icon="terp-accessories-archiver" context="{'group_by':'res_id'}"/>
                    <filter string="State" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
                    <separator orientation="vertical"/>
                    <filter string="Partner" icon="terp-partner" context="{'group_by':'partner_id'}"/>
                    <separator orientation="vertical"/>
                    <filter string="Day" icon="terp-go-today" context="{'group_by':'day'}"/>
                    <filter string="Month" icon="terp-go-month" context="{'group_by':'month'}"/>
                    <filter string="Year" icon="terp-go-year" context="{'group_by':'year'}"/>
                </group>
            </search>
        </field>
    </record>

    <record id="action_campaign_analysis_all" model="ir.actions.act_window">
        <field name="name">Campaign Analysis</field>
        <field name="res_model">campaign.analysis</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree</field>
        <field name="context">{'group_by': [], 'search_default_Campaign': 1, 'search_default_Segment': 1, 'group_by_no_leaf':1}</field>
        <field name="search_view_id" ref="view_campaign_analysis_search"/>
    </record>

    <menuitem name="Reporting" id="base.menu_report_marketing" parent="base.marketing_menu"/>
    <menuitem action="action_campaign_analysis_all" id="menu_action_campaign_analysis_all" parent="base.menu_report_marketing" sequence="2"/>

    </data>
</openerp>
