<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>

<!-- CRM Claim Report Tree View -->

        <record id="view_report_crm_claim_tree" model="ir.ui.view">
            <field name="name">crm.claim.report.tree</field>
            <field name="model">crm.claim.report</field>
            <field name="arch" type="xml">
               <tree string="Claims" create="false">
                    <field name="name" invisible="1"/>
                    <field name="month" invisible="1"/>
                    <field name="section_id" invisible="1"/>
                    <field name="user_id" invisible="1"/>
                    <field name="company_id" invisible="1"/>
                    <field name="partner_id" invisible="1"/>
                    <field name="day" invisible="1"/>
                    <field name="nbr" string="#Claim" sum="#Claim"/>
                    <field name="email" sum="# Mails"/>
                    <field name="delay_close" avg="Avg Closing Delay"/>
                    <field name="delay_expected"/>
                    <field name="state" invisible="1"/>
                    <field name="stage_id" invisible="1"/>
                    <field name="categ_id" invisible="1"/>
                    <field name="priority" invisible="1"/>
                    <field name="type_action" invisible="1"/>
                </tree>
            </field>
        </record>

<!-- CRM Claim Report Graph View -->

        <record id="view_report_crm_claim_graph" model="ir.ui.view">
            <field name="name">crm.claim.report.graph</field>
            <field name="model">crm.claim.report</field>
            <field name="arch" type="xml">
                <graph orientation="horizontal" string="Claims" type="bar">
                    <field name="state"/>
                    <field name="nbr" operator="+"/>
                    <field group="True" name="user_id"/>
                </graph>
            </field>
        </record>

<!-- CRM Claim Report Search View -->

        <record id="view_report_crm_claim_filter" model="ir.ui.view">
            <field name="name">crm.claim.report.select</field>
            <field name="model">crm.claim.report</field>
            <field name="arch" type="xml">
                <search string="Search">
                    <filter icon="terp-document-new" string="New" domain="[('state','=','draft')]"/>
                    <filter icon="terp-camera_test" string="Open" domain="[('state','=','open')]"/>
                    <filter icon="terp-gtk-media-pause" string="Pending" domain="[('state','=','pending')]"/>
                    <separator/>
                    <filter string="My Sales Team(s)" icon="terp-personal+" context="{'invisible_section': False}" domain="[('section_id.user_id','=',uid)]" help="My Sales Team(s)" />
                    <separator/>
                    <!-- A 'My Company' filter makes no sense regarding record rules, and is not possible to do (uid is not a company): remove me in 8.0 -->
                    <filter string="My Company" icon="terp-go-home" context="{'invisible_section': False}" domain="[]" help="My company"
                        invisible="1"/>
                    <separator/>
                    <filter icon="terp-personal" string="My Case(s)" help="My Case(s)" domain="[('user_id','=',uid)]" />
                    <field name="company_id" groups="base.group_multi_company"/>
                    <field name="user_id" string="Salesperson"/>
                    <field name="section_id" string="Sales Team" context="{'invisible_section': False}"/>
                    <group  expand="0" string="Extended Filters...">
                        <field name="partner_id" filter_domain="[('partner_id','child_of',self)]"/>
                        <field name="stage_id" domain="[('section_ids', '=', 'section_id')]"/>
                        <field name="categ_id" domain="[('object_id.model', '=', 'crm.claim')]"/>
                        <field name="priority"/>
                        <field name="type_action"/>
                        <field name="create_date" />
                        <field name="date_closed" />
                        <field name="date_deadline" />
                        <filter icon="terp-dialog-close" string="Done" domain="[('state','=','done')]"/>
                        <filter icon="gtk-cancel" string="Cancel" domain="[('state','=','cancel')]"/>
                    </group>
                    <group  expand="1" string="Group By...">
                        <filter string="Salesperson" name="Salesperson" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}" />
                        <filter string="Sales Team" icon="terp-personal+" domain="[]" context="{'group_by':'section_id'}" />
                        <filter string="Partner" name="partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}" />
                        <filter string="Stage" icon="terp-stage" domain="[]" context="{'group_by':'stage_id'}" />
                        <filter string="Priority" icon="terp-rating-rated" domain="[]" context="{'group_by':'priority'}" />
                        <filter string="Category" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by':'categ_id'}" />
                        <filter string="Type" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by':'type_action'}" help="Action Type"/>
                        <filter string="Status" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'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-today" domain="[]" context="{'group_by':'day'}" help="Date of claim"/>
                        <filter string="Month" icon="terp-go-month" domain="[]" context="{'group_by':'month'}" help="Month of claim"/>
                        <filter string="Year" icon="terp-go-year" domain="[]" context="{'group_by':'name'}" help="Year of claim"/>
                    </group>
                </search>
            </field>
        </record>

<!-- CRM Claim Report Action -->

        <record id="action_report_crm_claim" model="ir.actions.act_window">
            <field name="name">Claims Analysis</field>
            <field name="res_model">crm.claim.report</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,graph</field>
            <field name="context">{"search_default_year":1,"search_default_User":1,"search_default_This Month":1,'group_by_no_leaf':1,'group_by':[]}</field>
            <field name="view_id" ref="view_report_crm_claim_tree"/>
            <field name="search_view_id" ref="view_report_crm_claim_filter"/>
            <field name="help">Have a general overview of all claims processed in the system by sorting them with specific criteria.</field>
        </record>

        <record model="ir.actions.act_window.view" id="action_report_crm_claim_tree">
            <field name="sequence" eval="1"/>
            <field name="view_mode">tree</field>
            <field name="view_id" ref="view_report_crm_claim_tree"/>
            <field name="act_window_id" ref="action_report_crm_claim"/>
        </record>

        <record model="ir.actions.act_window.view" id="action_report_crm_claim_graph">
            <field name="sequence" eval="2"/>
            <field name="view_mode">graph</field>
            <field name="view_id" ref="view_report_crm_claim_graph"/>
            <field name="act_window_id" ref="action_report_crm_claim"/>
        </record>

        <menuitem id="base.menu_project_report" name="Project"
            groups="base.group_no_one"
            parent="base.menu_reporting" sequence="30"/>

        <menuitem name="Claims Analysis" id="menu_report_crm_claim_tree"
            action="action_report_crm_claim" parent="base.menu_project_report" sequence="15"/>


    </data>
</openerp>
