<?xml version="1.0"?>
<openerp>
     <data>
          <record model="board.note.type" id="note_crm_type">
               <field name="name">CRM Configuration</field>
          </record>

          <record model="ir.ui.view" id="view_crm_opportunity_user_graph1">
               <field name="name">crm.opportunity.user.graph1</field>
               <field name="model">crm.lead.report</field>
               <field name="type">graph</field>
               <field name="arch" type="xml">
                    <graph string="Opportunities by User and Team" type="bar">
                         <field name="stage_id"/>
                         <field name="nbr" operator="+"/>
                         <field name="user_id" group="True"/>
                    </graph>
               </field>
          </record>
          
        <record id="view_report_crm_oppor_graph" model="ir.ui.view">
            <field name="name">crm.lead.report.graph</field>
            <field name="model">crm.lead.report</field>
            <field name="type">graph</field>
            <field name="arch" type="xml">
                <graph orientation="vertical" string="Opportunity Analysis" type="bar">
                   <field name="stage_id"/>
                    <field name="planned_revenue" operator="+"/>
                </graph>
            </field>
        </record>
        
        <record model="ir.ui.view" id="crm_case_my_open_oppor">
            <field name="name">Opportunities</field>
            <field name="model">crm.lead</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Opportunities"  colors="blue:state=='pending';grey:state in ('cancel', 'done');red:date_deadline and (date_deadline &lt; current_date)">
                    <field name="name" string="Opportunity"/>
                    <field name="partner_id"/>
                    <field name="stage_id"/>
                    <button name="stage_previous" string="Previous Stage"
                        states="open,pending" type="object" icon="gtk-go-back" />
                    <button name="stage_next" string="Next Stage"
                        states="open,pending" type="object"
                        icon="gtk-go-forward" />
                    <field name="planned_revenue" sum="Total of Planned Revenue"/>
                    <field name="probability" widget="progressbar" avg="Avg. of Probability"/>
                    <field name="date_deadline" invisible="1"/>
                    <field name="state"/>
                    <button name="case_open" string="Open"
                        states="draft,pending" type="object"
                        icon="gtk-go-forward" />
                    <button name="case_pending" string="Pending"
                        states="open,draft" type="object"
                        icon="gtk-media-pause" />
                    <button name="case_mark_lost" string="Lost"
                        states="open,pending" type="object"
                        icon="gtk-cancel" />
                    <button name="case_close" string="Won"
                        states="open,draft,pending" type="object"
                        icon="gtk-apply" />
                </tree>
            </field>
        </record>

          <record model="ir.actions.act_window" id="act_my_oppor">
              <field name="name">My Open Opportunities</field>
               <field name="res_model">crm.lead</field>
               <field name="view_type">form</field>
               <field name="view_mode">tree,form</field>
            <field name="domain">[('user_id','=',uid),('state','=','open'), ('type', '=', 'opportunity')]</field>
          </record>
        
        <record model="ir.actions.act_window.view" id="act_my_oppor_tree_view">
          <field name="sequence" eval="1"/>
          <field name="view_mode">tree</field>
          <field name="view_id" ref="crm_case_my_open_oppor"/>
          <field name="act_window_id" ref="act_my_oppor"/>
         </record>

        <record model="ir.actions.act_window.view" id="act_my_oppor_form_view">
            <field name="sequence" eval="2"/>
            <field name="view_mode">form</field>
            <field name="view_id" ref="crm_case_form_view_oppor"/>
            <field name="act_window_id" ref="act_my_oppor"/>
        </record>

          <record model="ir.actions.act_window" id="act_my_meetings">
               <field name="res_model">crm.meeting</field>
               <field name="view_type">form</field>
               <field name="view_mode">tree,form</field>
               <field name="view_id" ref="crm.crm_case_tree_view_meet"/>
            <field name="domain">[('user_id','=',uid),('state','not in',('cancel','done'))]</field>
          </record>

          <record model="ir.actions.act_window" id="act_my_oppor_stage">
               <field name="res_model">crm.lead.report</field>
               <field name="view_type">form</field>
               <field name="view_mode">graph,tree,form</field>
               <field name="view_id" ref="view_report_crm_oppor_graph"/>
            <field name="domain">['&amp;', '&amp;', ('user_id','=',uid), ('type', '=', 'opportunity'), '!' , '&amp;', ('state', '=', 'done'),  ('date_closed','&gt;',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%Y-%m-%d'))]</field>
          </record>

          <record model="ir.actions.act_window" id="act_sales_pipeline">
               <field name="res_model">crm.lead.report</field>
               <field name="view_type">form</field>
               <field name="view_mode">graph,tree,form</field>
               <field name="view_id" ref="view_crm_opportunity_user_graph1"/>
               <field name="domain">['&amp;', ('user_id', '=', uid),'&amp;', ('state', '=', 'done') , '&amp;', ('create_date','&gt;',(datetime.date.today()-datetime.timedelta(days=365)).strftime('%Y-%m-%d')), ('type', '=', 'opportunity')]</field>
          </record>

          <record model="ir.ui.view" id="board_crm_form">
               <field name="name">CRM - Dashboard Form</field>
               <field name="model">board.board</field>
               <field name="type">form</field>
               <field name="arch" type="xml">
                    <form string="Connecting Dashboard">
                         <hpaned>
                              <child1>
                                   <action
                                        string="My Open Opportunities"
                                        name="%(act_my_oppor)d"
                                        colspan="4"
                                        height="150"
                                        width="510"/>
                                   <action
                                        string="My Meetings"
                                        name="%(act_my_meetings)d"
                                        height="150"
                                        colspan="4"/>
                              </child1>
                              <child2>
                                   <action
                                string="My Planned Revenues by Stage"
                                name="%(act_my_oppor_stage)d"
                                colspan="4"/>
                            <action
                                string="My Win/Lost Ratio for the Last Year"
                                name="%(act_sales_pipeline)d"
                                colspan="4"/>
                        </child2>
                    </hpaned>
                </form>
            </field>
        </record>
        <record model="ir.actions.act_window" id="open_board_crm">
            <field name="name">CRM 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_form"/>
        </record>
         <menuitem id="board.menu_dasboard" name="Dashboard" sequence="0" parent="base.next_id_64"/>
        <menuitem
            name="Connecting Dashboard" parent="board.menu_dasboard"
            action="open_board_crm"
            sequence="1"
            id="menu_board_crm" icon="terp-graph"/>
        <menuitem icon="terp-partner" id="base.menu_base_partner" name="Sales" sequence="0" groups="base.group_sale_salesman,base.group_sale_manager,base.group_system,base.group_partner_manager" action="open_board_crm"/>
    </data>
</openerp>
