<?xml version="1.0"?>
<openerp>
    <data>
        <!--
         Board for statistical view of the sections
         -->
        <record model="ir.ui.view" id="view_crm_lead_stage_graph1">
            <field name="name">Leads By Stage - Graph</field>
            <field name="model">report.crm.case.section.stage</field>
            <field name="type">graph</field>
            <field name="arch" type="xml">
                <graph string="Leads By Stage" type="pie">
                    <field name="stage_id"/>
                    <field name="nbr" operator="+"/>
                    <field name="state" group="True"/>
                </graph>
            </field>
        </record>
        
        <record model="ir.ui.view" id="view_crm_case_categ_graph">
            <field name="name">report.crm.case.categ.graph</field>
            <field name="model">report.crm.case.categ</field>
            <field name="type">graph</field>
            <field name="arch" type="xml">
                <graph string="Cases by Sections and Categories" type="bar" orientation="horizontal">
                    <field name="categ_id"/>
                    <field name="nbr" operator="+"/>
                    <field name="state" group="True"/>
                </graph>
            </field>
        </record>         
        
        <act_window name="Opportunities By Categories"
            domain="[('section_id', '=', 'Opportunities'),('state','!=','done'),('state','!=','cancel')]"
            res_model="report.crm.case.categ"
            view_type="form"
            view_mode="graph,tree,form"
            view_id="view_crm_case_categ_graph"
            id="act_oppor_categ"/>         
            
        <record model="ir.actions.act_window" id="act_leads_state">
            <field name="res_model">report.crm.case.section.stage</field>
            <field name="view_type">form</field>
            <field name="view_mode">graph,tree,form</field>
            <field name="view_id" ref="view_crm_lead_stage_graph1"/>
            <field name="domain">[('section_id', '=', 'Leads'),('state','!=','done'),('state','!=','cancel')]</field>
        </record>    
        
        <act_window name="Jobs Requests Of The Month by Applied Job"
            domain="[('section_id', '=', 'Jobs'),('name','=',time.strftime('%Y-%m-01')),('state','!=','done'),('state','!=','cancel')]"
            res_model="report.crm.case.categ"
            view_type="form"
            view_mode="graph,tree,form"
            view_id="view_crm_case_categ_graph"
            id="act_jobs_categ"/>
            
        <act_window name="Leads Of The Month By User"
            domain="[('section_id', '=', 'Leads'),('name','=',time.strftime('%Y-%m-01')),('state','!=','cancel')]"
            res_model="report.crm.case.user"
            view_type="form"
            view_mode="graph,tree,form"
            id="act_leads_month_user"/>
            
        <record model="ir.ui.view" id="board_crm_statistical_form">
            <field name="name">CRM - Statistical Dashboard Form</field>
            <field name="model">board.board</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Statistics Dashboard">
                    <hpaned>
                        <child1>
                            <action
                                string="Opportunities By Categories"
                                name="%(act_oppor_categ)d"
                                colspan="4"
                                height="200"
                                width="250"/>

                            <action
                                string="Leads By Stage"
                                name="%(act_leads_state)d"
                                height="200"
                                colspan="4"/>
                            
                        </child1>
                        <child2>
                            <action
                                string="Jobs Requests Of The Month by Applied Job"
                                name="%(act_jobs_categ)d"
                                colspan="4"/>


                            <action
                                string="Leads Of The Month By User"
                                name="%(act_leads_month_user)d"
                                colspan="4"/>

                        </child2>
                    </hpaned>
                </form>
            </field>
        </record>

        <record model="ir.actions.act_window" id="open_board_statistical_dash">
            <field name="name">CRM - Statistics Dashboard</field>
            <field name="res_model">board.board</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
            <field name="usage">menu</field>
            <field name="view_id" ref="board_crm_statistical_form"/>
        </record>

        <menuitem 
            name="CRM Configuration" parent="board.dashboard_menu"
            id="menu_board_crm_config"
            groups="crm.group_crm_manager"/>
        <menuitem
            name="Statistics Dashboard" parent="menu_board_crm_config"
            action="open_board_statistical_dash"
            sequence="2"
            id="menu_board_statistics_dash"
            icon="terp-graph"/>

    </data>
</openerp>
