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

        <!-- Report, event on registration -->
        <record model="ir.ui.view" id="report_event_registration_tree">
            <field name="name">report.event.registration.tree</field>
            <field name="model">report.event.registration</field>
            <field name="arch" type="xml">
                <tree colors="blue:event_state == 'draft';black:event_state == 'confirm';gray:event_state in('done','cancel')" create="false" string="Events Analysis">
                    <field name="event_date" invisible="1"/>
                    <field name="user_id" invisible="1"/>
                    <field name="speaker_id" invisible="1"/>
                    <field name="year" invisible="1"/>
                    <field name="month" invisible="1"/>
                    <field name="event_id" invisible="1"/>
                    <field name="event_state" invisible="1"/>
                    <field name="event_type" invisible="1"/>
                    <field name="nbevent"/>
                    <field name="draft_state" invisible="context.get('no_of_draft_invisible', False)"/>
                    <field name="confirm_state"/>
                    <field name="registration_state" invisible="1"/>
                    <field name="name_registration" invisible="1"/>
                    <field name="user_id_registration" invisible="1"/>
                    <field name="register_max" invisible="context.get('max_reg_event_visible', True)"/>
                    <field name="company_id" invisible="1"/>
                </tree>
            </field>
        </record>

        <record model ="ir.ui.view" id="report_event_registration_graph">
            <field name="name">report.event.registration.graph</field>
            <field name="model">report.event.registration</field>
            <field name="arch" type="xml">
                <graph orientation="horizontal" string="Event on Registration"  type="bar" >
                    <field name="event_id"/>
                    <field name="draft_state" operator="+"/>
                    <field name="confirm_state" operator="+"/>
                    <field name="register_max" operator="+"/>
                </graph>
            </field>
        </record>

        <!-- Event on Registration search view -->
        <record model="ir.ui.view" id="view_report_event_registration_search">
            <field name="name">report.event.registration.search</field>
            <field name="model">report.event.registration</field>
            <field name="arch" type="xml">
                <search string="Event on Registration">
                    <filter icon="terp-document-new" string="New" domain="[('event_state','=','draft')]" help="Events which are in New state"/>
                    <filter icon="terp-check" string="Confirm" domain="[('event_state','=','confirm')]" help="Events which are in confirm state"/>
                    <separator/>
                    <filter icon="terp-personal" string="My Events" help="My Events" domain="[('user_id','=',uid)]"/>
                    <field name="event_id" string="Event"/>
                    <field name="user_id"/>
                    <group expand="0" string="Extended Filters...">
                        <field name="event_type" widget="selection"/>
                        <field name="event_date"/>
                    </group>
                    <newline/>
                    <group expand="1" string="Group By...">
                        <filter string="Participant / Contact" icon="terp-personal" context="{'group_by':'name_registration'}" help="Registration contact"/>
                        <filter string="Register" icon="terp-personal" context="{'group_by':'user_id_registration'}" help="Registration contact" groups="base.group_no_one"/>
                        <filter string="Speaker" name="speaker" icon="terp-personal+" context="{'group_by': 'speaker_id'}" groups="base.group_no_one"/>
                        <filter string="Event Responsible" name="user_id" icon="terp-personal" context="{'group_by': 'user_id'}"/>
                        <filter string="Event" name="event" icon="terp-crm" context="{'group_by':'event_id', 'max_reg_event_visible':0}"/>
                        <filter string="Event Type" icon="terp-crm"  context="{'group_by':'event_type'}"/>
                        <filter string="Event State" icon="terp-stock_effects-object-colorize" context="{'group_by':'event_state'}"/>
                        <filter string="Registration State" icon="terp-stock_effects-object-colorize" context="{'group_by':'registration_state'}"/>
                        <filter string="Company" icon="terp-go-home" domain="[]" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
                        <filter string="Day" icon="terp-go-month" domain="[]" context="{'group_by':'event_date'}" help="Event Beginning Date"/>
                        <filter string="Month" icon="terp-go-month" domain="[]" context="{'group_by':'month'}" help="Event Beginning Date"/>
                        <filter string="Year" icon="terp-go-year" domain="[]" context="{'group_by':'year'}" help="Event Beginning Date"/>
                    </group>
                    <group expand="0" string="Display">
                        <filter icon="terp-camera_test" string="Show Confirmed Registrations"
                              help="Registrations in confirmed or done state" context="{'no_of_draft_invisible':1}"/>
                    </group>
                </search>
            </field>
        </record>

        <record model="ir.actions.act_window" id="action_report_event_registration">
            <field name="name">Events Analysis</field>
            <field name="res_model">report.event.registration</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,graph</field>
            <field name="search_view_id" ref="view_report_event_registration_search"/>
            <field name="context">{"search_default_year":1,"search_default_this_month":1,"search_default_365day":1, "search_default_invoiced":1, "search_default_event":1, "group_by_no_leaf":1, "group_by":[]}</field>
        </record>

        <record model="ir.actions.act_window.view" id="action_report_event_registration_tree">
            <field name="sequence" eval="1"/>
            <field name="view_mode">tree</field>
            <field name="view_id" ref="report_event_registration_tree"/>
            <field name="act_window_id" ref="action_report_event_registration"/>
        </record>

        <record model="ir.actions.act_window.view" id="action_report_event_registration_graph">
            <field name="sequence" eval="2"/>
            <field name="view_mode">graph</field>
            <field name="view_id" ref="report_event_registration_graph"/>
            <field name="act_window_id" ref="action_report_event_registration"/>
        </record>

        <menuitem parent="base.menu_reporting" id="menu_reporting_events" sequence="30" groups="event.group_event_manager" name="Events"/>
        <menuitem parent="menu_reporting_events" action="action_report_event_registration" id="menu_report_event_registration" sequence="3" groups="event.group_event_manager"/>

    </data>
</openerp>
