<?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_tree" model="ir.ui.view">
            <field name="name">report.project.task.user.tree</field>
            <field name="model">report.project.task.user</field>
            <field name="arch" type="xml">
                <tree string="Tasks Analysis" create="false">
                    <field name="name" invisible="1"/>
                    <field name="project_id" invisible="1"/>
                    <field name="user_id" invisible="1"/>
                    <field name="date_deadline" invisible="1"/>
                    <field name="state" invisible="1"/>
                    <field name="date_start" invisible="1"/>
                    <field name="date_end" invisible="1"/>
                    <field name="company_id" invisible="1" groups="base.group_multi_company"/>
                    <field name="partner_id" invisible="1"/>
                    <field name="day" invisible="1"/>
                    <field name="month" invisible="1"/>
                    <field name="year" invisible="1"/>
                    <field name="nbr" sum='# of tasks'/>
                    <field name="no_of_days" sum="# of Days"/>
                    <field name="total_hours" sum='Total Hours'/>
                    <field name="hours_planned" sum='Planned Hours'/>
                    <field name="remaining_hours" sum='Remaining Hours'/>
                    <field name="hours_effective" sum='Effective Hours'/>
                    <field name="hours_delay" sum='Avg. Plan.-Eff.'/>
                    <field name="opening_days" sum='Days to Open'/>
                    <field name="closing_days" sum='Days to Close'/>
                    <field name="delay_endings_days" sum='OverPass delay'/>
                    <field name="progress" sum='Progress' widget='progressbar'/>
                </tree>
            </field>
        </record>

        <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="bar">
                     <field name="name"/>
                     <field name="state" group="True"/>
                     <field name="no_of_days" operator="+"/>
                 </graph>
             </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"/>
                    <filter string="New" icon="terp-document-new" domain="[('state','=','draft')]" help = "New tasks"/>
                    <filter string="In progress" icon="terp-check" domain="[('state', '=' ,'open')]" help = "In progress tasks"/>
                    <filter string="Pending" icon="terp-gtk-media-pause" domain="[('state','=','pending')]" help = "Pending tasks"/>
                    <filter string="Done" icon="terp-dialog-close" name="done" domain="[('state','=','done')]"/>
                    <separator/>
                    <filter icon="terp-folder-violet" string="My Projects" help="My Projects" domain="[('project_id.user_id','=',uid)]"/>
                    <separator/>
                    <filter icon="terp-personal" string="My Task" help = "My tasks" domain="[('user_id','=',uid)]" />
                    <filter icon="terp-personal-" string="Non Assigned Tasks to users" help="Non Assigned Tasks to users" domain="[('user_id','=',False)]"/>
                    <field name="project_id"/>
                    <field name="user_id"/>
                    <field name="partner_id" filter_domain="[('partner_id', 'child_of', self)]"/>
                    <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" icon="terp-folder-violet" context="{'group_by':'project_id'}"/>
                        <filter string="Task" icon="terp-stock_align_left_24" context="{'group_by':'name'}" />
                        <filter string="Contact" icon="terp-partner" context="{'group_by':'partner_id'}" />
                        <filter string="Assigned to" name="User" icon="terp-personal" context="{'group_by':'user_id'}" />
                        <filter string="Company" icon="terp-go-home" context="{'group_by':'company_id'}"  groups="base.group_multi_company"/>
                        <filter string="Day" icon="terp-go-today" context="{'group_by':'day'}" help="Creation Date"/>
                        <filter string="Month" icon="terp-go-month" context="{'group_by':'month'}" help="Creation Date"/>
                        <filter string="Year" icon="terp-go-year" context="{'group_by':'year'}" 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">tree,graph</field>
            <field name="search_view_id" ref="view_task_project_user_search"/>
            <field name="context">{'search_default_year':1,'search_default_project':1,'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>
