<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <record id="view_report_crm_claim_pivot" model="ir.ui.view">
        <field name="name">crm.claim.report.pivot</field>
        <field name="model">crm.claim.report</field>
        <field name="arch" type="xml">
            <pivot string="Claims" disable_linking="True">
                <field name="stage_id" type="row" />
                <field name="team_id" type="col" />
                <field name="nbr_claims" type="measure" />
            </pivot>
        </field>
    </record>
    <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 string="Claims">
                <field name="stage_id" />
                <field name="team_id" />
                <field name="nbr_claims" type="measure" />
            </graph>
        </field>
    </record>
    <record id="filter_report_crm_claim_workload" model="ir.filters">
        <field name="name">Workload</field>
        <field name="model_id">crm.claim.report</field>
        <field name="user_id" eval="False" />
        <field
            name="context"
        >{'group_by': ['subject'], 'measures': ['email', 'delay_close']}</field>
    </record>
    <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
                    string="My Sales Team(s)"
                    name="My Sales Team(s)"
                    context="{'invisible_team': False}"
                    domain="[('team_id.user_id','=',uid)]"
                    help="My Sales Team(s)"
                />
                <separator />
                <filter
                    string="My Company"
                    name="My Company"
                    domain="[('company_id.user_ids','=',uid)]"
                    help="My Company"
                    groups="base.group_multi_company"
                />
                <separator />
                <field name="company_id" groups="base.group_multi_company" />
                <field name="user_id" string="Salesperson" />
                <field
                    name="team_id"
                    string="Sales Team"
                    context="{'invisible_team': False}"
                />
                <group expand="0" string="Extended Filters...">
                    <field
                        name="partner_id"
                        filter_domain="[('partner_id','child_of',self)]"
                    />
                    <field name="stage_id" domain="[('team_ids', '=', 'team_id')]" />
                    <field name="categ_id" />
                    <field name="priority" />
                    <field name="type_action" />
                    <field name="create_date" />
                    <field name="date_closed" />
                    <field name="date_deadline" />
                </group>
                <group expand="1" string="Group By">
                    <filter
                        string="Salesperson"
                        name="Salesperson"
                        context="{'group_by':'user_id'}"
                    />
                    <filter
                        string="Partner"
                        name="partner"
                        context="{'group_by':'partner_id'}"
                    />
                    <filter
                        string="Stage"
                        name="Stage"
                        context="{'group_by':'stage_id'}"
                    />
                    <filter
                        string="Category"
                        name="Category"
                        context="{'group_by':'categ_id'}"
                    />
                    <filter
                        string="Company"
                        name="Company"
                        context="{'group_by':'company_id'}"
                        groups="base.group_multi_company"
                    />
                    <separator />
                    <filter
                        string="Creation Month"
                        name="Creation Month"
                        context="{'group_by':'claim_date:month'}"
                        help="Month of claim"
                    />
                </group>
            </search>
        </field>
    </record>
    <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_mode">pivot,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="search_view_id" ref="view_report_crm_claim_filter" />
        <field name="view_id" />
        <!-- force empty -->
        <field
            name="help"
        >Have a general overview of all claims processed in the system by sorting them with specific criteria.</field>
    </record>
    <menuitem
        name="Claims"
        id="menu_report_crm_claim_tree"
        action="action_report_crm_claim"
        parent="crm.crm_menu_report"
        sequence="15"
    />
</odoo>
