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

        <menuitem id="base.menu_project_report" name="Project"
            groups="project.group_project_manager"
            parent="base.menu_reporting" sequence="25"/>

        <record id="view_task_project_user_graph" model="ir.ui.view">
            <field name="name">report.project.task.user.graph</field>
            <field name="model">report.project.task.user</field>
            <field name="arch" type="xml">
                <graph string="Tasks Analysis" type="pivot">
                     <field name="project_id" type="row"/>
                     <field name="user_id" type="col"/>
                     <field name="nbr" type="measure"/>
                 </graph>
             </field>
        </record>

        <!-- Custom reports (aka filters) -->
        <record id="filter_task_report_task_pipe" model="ir.filters">
            <field name="name">Task Pipe</field>
            <field name="model_id">report.project.task.user</field>
            <field name="user_id" eval="False"/>
            <field name="context">{'group_by': ['project_id'], 'col_group_by': ['stage_id'], 'measures': ['nbr']}</field>
        </record>
        <record id="filter_task_report_workload" model="ir.filters">
            <field name="name">Workload</field>
            <field name="model_id">report.project.task.user</field>
            <field name="user_id" eval="False"/>
            <field name="context">{'group_by': ['project_id'], 'measures': ['total_hours','hours_planned','remaining_hours']}</field>
        </record>
        <record id="filter_task_report_responsible" model="ir.filters">
            <field name="name">By Responsible</field>
            <field name="model_id">report.project.task.user</field>
            <field name="user_id" eval="False"/>
            <field name="context">{'group_by': ['project_id', 'user_id']}</field>
        </record>
        <record id="filter_task_report_reviewer" model="ir.filters">
            <field name="name">By Reviewer</field>
            <field name="model_id">report.project.task.user</field>
            <field name="user_id" eval="False"/>
            <field name="context">{'group_by': ['project_id', 'reviewer_id']}</field>
        </record>

        <record id="view_task_project_user_search" model="ir.ui.view">
            <field name="name">report.project.task.user.search</field>
            <field name="model">report.project.task.user</field>
            <field name="arch" type="xml">
                <search string="Tasks Analysis">
                    <field name="date_start"/>
                    <field name="date_end"/>
                    <field name="date_deadline"/>
                    <field name="date_last_stage_update"/>
                    <field name="project_id"/>
                    <field name="user_id"/>
                    <field name="partner_id" filter_domain="[('partner_id', 'child_of', self)]"/>
                    <field name="stage_id"/>
                    <filter string="My Task" domain="[('user_id','=',uid)]"/>
                    <filter string="Unassigned" name="unassigned" domain="[('user_id','=',False)]"/>
                    <separator/>
                    <filter string="New" name="new" domain="[('stage_id.sequence', '&lt;=', 1)]"/>
                    <group expand="0" string="Extended Filters">
                        <field name="priority"/>
                        <field name="company_id" groups="base.group_multi_company"/>
                    </group>
                    <group expand="1" string="Group By">
                        <filter string="Project" name="project" context="{'group_by':'project_id'}"/>
                        <filter string="Task" context="{'group_by':'name'}"/>
                        <filter string="Assigned to" name="User" context="{'group_by':'user_id'}"/>
                        <filter string="Stage" name="Stage" context="{'group_by':'stage_id'}"/>
                        <filter string="Company" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
                        <separator/>
                        <filter string="Assignation Month" context="{'group_by':'date_start:month'}" help="Creation Date"/>
                    </group>
                </search>
            </field>
        </record>

       <record id="action_project_task_user_tree" model="ir.actions.act_window">
            <field name="name">Tasks Analysis</field>
            <field name="res_model">report.project.task.user</field>
            <field name="view_type">form</field>
            <field name="view_mode">graph</field>
            <field name="search_view_id" ref="view_task_project_user_search"/>
            <field name="context">{'group_by_no_leaf':1,'group_by':[]}</field>
            <field name="help">This report allows you to analyse the performance of your projects and users. You can analyse the quantities of tasks, the hours spent compared to the planned hours, the average number of days to open or close a task, etc.</field>
        </record>

        <menuitem action="action_project_task_user_tree" id="menu_project_task_user_tree" parent="base.menu_project_report"/>

    </data>
</openerp>
