<?xml version="1.0"?>
<openerp>
    <data>
        <!-- REPORTING/MEMBERSHIP BY YEAR  -->


        <record model="ir.ui.view" id="view_report_membership_tree1">
            <field name="name">report.membership.tree</field>
            <field name="model">report.membership</field>
            <field name="arch" type="xml">
                <tree colors="blue:membership_state == 'draft';black:membership_state in ('open','free');gray:membership_state in ('done','cancel') " create="false" string="Membership">
                    <field name="partner_id"/>
                    <field name="membership_state"/>
                    <field name="associate_member_id" invisible="1"/>
                    <field name="date_from"/>
                    <field name="date_to"/>
                    <field name="user_id" invisible="1"/>
                    <field name="membership_id"/>
                    <field name="num_waiting" invisible="context.get('waiting_invoiced_totpending_visible', True)"/>
                    <field name="num_invoiced" invisible="context.get('waiting_invoiced_totpending_visible', True)"/>
                    <field name="tot_pending" invisible="context.get('waiting_invoiced_totpending_visible', True)"/>
                    <field name="num_paid" invisible="context.get('paid_old_totearned_visible', True)"/>
                    <field name="tot_earned" invisible="context.get('paid_old_totearned_visible', True)"/>
                    <field name="year" invisible="1"/>
                    <field name="month" invisible="1"/>
                    <field name="company_id" invisible="1"/>
                </tree>
            </field>
        </record>

        <record model="ir.ui.view" id="view_report_membership_search">
            <field name="name">report.membership.search</field>
            <field name="model">report.membership</field>
            <field name="arch" type="xml">
                <search string="Membership">
                    <field name="date_from"/>
                    <filter string="Forecast" icon="terp-gtk-jump-to-ltr" context="{'waiting_invoiced_totpending_visible':0}" help="This will display waiting, invoiced and total pending columns"/>
                    <filter string="Revenue Done" name="Revenue" icon="terp-dolar" context="{'paid_old_totearned_visible':0}" help="This will display paid, old and total earned columns"/>
                    <field name="partner_id"/>
                    <field name="membership_id"/>
                    <field name="user_id"/>
                    <group expand="1" string="Group By...">
                        <filter string="Salesperson" icon="terp-personal" name="salesman"
                            domain="[]" context="{'group_by':'user_id'}"/>
                        <filter string="Associated Partner" icon="terp-partner" name="associate_member_id"
                            domain="[]" context="{'group_by':'associate_member_id'}"/>
                        <filter string="Membership Product" icon="terp-accessories-archiver" name="product"
                            domain="[]" context="{'group_by':'membership_id'}"/>
                        <filter string="Current Membership State" icon="terp-stock_effects-object-colorize"
                            domain="[]" context="{'group_by':'membership_state'}"/>
                        <filter string="Company" icon="terp-go-home"
                            domain="[]" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
                        <filter string="Year" name="year" icon="terp-go-year"
                            domain="[]" context="{'group_by':'year'}"/>
                        <filter string="Month" name="month" icon="terp-go-month"
                            domain="[]" context="{'group_by':'month'}"/>
                    </group>
                </search>
            </field>
        </record>

        <record model="ir.ui.view" id="view_report_membership_graph1">
            <field name="name">report.membership.graph1</field>
            <field name="model">report.membership</field>
            <field name="arch" type="xml">
                <graph string="Membership" type="bar">
                    <field name="year" />
                    <field name="num_waiting" operator="+"/>
                    <field name="num_invoiced" operator="+"/>
                    <field name="num_paid" operator="+"/>
                </graph>
            </field>
        </record>

        <record model="ir.actions.act_window" id="action_report_membership_tree">
            <field name="name">Members Analysis</field>
            <field name="res_model">report.membership</field>
            <field name="view_type">form</field>
            <field name="search_view_id" ref="view_report_membership_search"/>
            <field name="context">{"search_default_year":1,"search_default_member":1, 'search_default_Revenue':1, 'search_default_this_month':1, 'search_default_salesman':1,'group_by_no_leaf':1}</field>
        </record>

        <record model="ir.actions.act_window.view" id="action_report_membership_tree_view1">
            <field name="sequence" eval="1"/>
            <field name="view_mode">tree</field>
            <field name="view_id" ref="view_report_membership_tree1"/>
            <field name="act_window_id" ref="action_report_membership_tree"/>
        </record>


        <record model="ir.actions.act_window.view" id="action_report_membership_tree_view2">
            <field name="sequence" eval="3"/>
            <field name="view_mode">graph</field>
            <field name="view_id" ref="view_report_membership_graph1"/>
            <field name="act_window_id" ref="action_report_membership_tree"/>
        </record>

        <menuitem name="Members Analysis" parent="base.menu_report_association"
            action="action_report_membership_tree"
            id="menu_report_membership"
            groups="base.group_partner_manager"/>

    </data>
</openerp>
