<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <record id="timesheets_analysis_report_list" model="ir.ui.view">
            <field name="name">timesheets.analysis.report.list</field>
            <field name="model">timesheets.analysis.report</field>
            <field name="arch" type="xml">
                <list>
                    <field name="date"/>
                    <field name="employee_id"/>
                    <field name="project_id"/>
                    <field name="task_id"/>
                    <field name="currency_id" column_invisible="1"/>
                    <field name="amount" string="Timesheet Costs" optional="hide" sum="Total"/>
                    <field name="unit_amount" optional="show" widget="timesheet_uom" sum="Total"
                        decoration-danger="unit_amount &gt; 24 or unit_amount &lt; 0"
                        decoration-muted="unit_amount == 0"
                    />
                </list>
            </field>
        </record>

        <record id="timesheets_analysis_report_form" model="ir.ui.view">
            <field name="name">timesheets.analysis.report.form</field>
            <field name="model">timesheets.analysis.report</field>
            <field name="arch" type="xml">
                <form string="Timesheets Analysis">
                    <sheet>
                        <group>
                            <group>
                                <field name="project_id"/>
                                <field name="task_id"/>
                            </group>
                            <group>
                                <field name="employee_id"/>
                                <field name="date"/>
                                <field name="amount" invisible="1"/>
                                <field name="unit_amount" string="Time Spent" widget="timesheet_uom" decoration-danger="unit_amount &gt; 24"
                                    decoration-muted="unit_amount == 0"/>
                            </group>
                        </group>
                        <field name="name" widget="text" nolabel="1"/>
                    </sheet>
                </form>
            </field>
        </record>

        <record id="timesheets_analysis_report_pivot_employee" model="ir.ui.view">
            <field name="name">timesheets.analysis.report.pivot</field>
            <field name="model">timesheets.analysis.report</field>
            <field name="arch" type="xml">
                <pivot string="Timesheets Analysis" sample="1">
                    <field name="employee_id" type="row"/>
                    <field name="date" interval="month" type="col"/>
                    <field name="amount" string="Timesheet Costs"/>
                    <field name="unit_amount" type="measure" widget="timesheet_uom"/>
                </pivot>
            </field>
        </record>

        <record id="timesheets_analysis_report_graph_employee" model="ir.ui.view">
            <field name="name">timesheets.analysis.report.graph</field>
            <field name="model">timesheets.analysis.report</field>
            <field name="arch" type="xml">
                <graph string="Timesheets" sample="1" js_class="hr_timesheet_graphview">
                    <field name="employee_id" type="row"/>
                    <field name="amount" string="Timesheet Costs"/>
                    <field name="unit_amount" type="measure" widget="timesheet_uom"/>
                </graph>
            </field>
        </record>

        <record id="timesheets_analysis_report_pivot_project" model="ir.ui.view">
            <field name="name">timesheets.analysis.report.pivot</field>
            <field name="model">timesheets.analysis.report</field>
            <field name="arch" type="xml">
                <pivot string="Timesheets Analysis" sample="1">
                    <field name="project_id" type="row"/>
                    <field name="date" interval="month" type="col"/>
                    <field name="amount" string="Timesheet Costs"/>
                    <field name="unit_amount" type="measure" widget="timesheet_uom"/>
                </pivot>
            </field>
        </record>

        <record id="timesheets_analysis_report_graph_project" model="ir.ui.view">
            <field name="name">timesheets.analysis.report.graph</field>
            <field name="model">timesheets.analysis.report</field>
            <field name="arch" type="xml">
                <graph string="Timesheets" sample="1" js_class="hr_timesheet_graphview">
                    <field name="project_id" type="row"/>
                    <field name="amount" string="Timesheet Costs"/>
                    <field name="unit_amount" type="measure" widget="timesheet_uom"/>
                </graph>
            </field>
        </record>

        <record id="timesheets_analysis_report_pivot_task" model="ir.ui.view">
            <field name="name">timesheets.analysis.report.pivot</field>
            <field name="model">timesheets.analysis.report</field>
            <field name="arch" type="xml">
                <pivot string="Timesheets Analysis" sample="1">
                    <field name="amount" string="Timesheet Costs"/>
                    <field name="project_id" type="row"/>
                    <field name="task_id" type="row"/>
                    <field name="date" interval="month" type="col"/>
                    <field name="unit_amount" type="measure" widget="timesheet_uom"/>
                </pivot>
            </field>
        </record>

        <record id="timesheets_analysis_report_graph_task" model="ir.ui.view">
            <field name="name">timesheets.analysis.report.graph</field>
            <field name="model">timesheets.analysis.report</field>
            <field name="arch" type="xml">
                <graph string="Timesheets" sample="1" js_class="hr_timesheet_graphview">
                    <field name="project_id" type="row"/>
                    <field name="task_id" type="row"/>
                    <field name="amount" string="Timesheet Costs"/>
                    <field name="unit_amount" type="measure" widget="timesheet_uom"/>
                </graph>
            </field>
        </record>

        <record id="hr_timesheet_report_search" model="ir.ui.view">
            <field name="name">timesheets.analysis.report.search</field>
            <field name="model">timesheets.analysis.report</field>
            <field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_search"/>
            <field name="mode">primary</field>
            <field name="arch" type="xml">
                <search position="attributes">
                    <attribute name="string">Timesheet Report</attribute>
                </search>
            </field>
        </record>

        <!-- Group by employee -->
        <record id="act_hr_timesheet_report" model="ir.actions.act_window">
            <field name="name">Timesheets by Employee</field>
            <field name="res_model">timesheets.analysis.report</field>
            <field name="path">timesheets-by-employee</field>
            <field name="domain">[('project_id', '!=', False)]</field>
            <field name="context">{}</field>
            <field name="search_view_id" ref="hr_timesheet_report_search"/>
            <field name="view_mode">pivot,graph</field>
            <field name="help" type="html">
              <p class="o_view_nocontent_empty_folder">
                No data yet!
              </p><p>
                Analyze the projects and tasks on which your employees spend their time.<br/>
                Evaluate which part is billable and what costs it represents.
              </p>
            </field>
        </record>

        <record model="ir.actions.act_window.view" id="act_hr_timesheet_report_pivot">
            <field name="sequence" eval="5"/>
            <field name="view_mode">pivot</field>
            <field name="view_id" ref="hr_timesheet.timesheets_analysis_report_pivot_employee"/>
            <field name="act_window_id" ref="act_hr_timesheet_report"/>
        </record>

        <record id="timesheet_action_view_report_by_employee_graph" model="ir.actions.act_window.view">
            <field name="sequence" eval="6"/>
            <field name="view_mode">graph</field>
            <field name="view_id" ref="hr_timesheet.timesheets_analysis_report_graph_employee"/>
            <field name="act_window_id" ref="act_hr_timesheet_report"/>
        </record>

        <record id="timesheet_action_view_report_by_employee_list" model="ir.actions.act_window.view">
            <field name="sequence" eval="10"/>
            <field name="view_mode">list</field>
            <field name="view_id" ref="hr_timesheet.timesheets_analysis_report_list"/>
            <field name="act_window_id" ref="act_hr_timesheet_report"/>
        </record>

        <!-- Group by project-->
        <record id="timesheet_action_report_by_project" model="ir.actions.act_window">
            <field name="name">Timesheets by Project</field>
            <field name="res_model">timesheets.analysis.report</field>
            <field name="path">timesheets-by-project</field>
            <field name="domain">[('project_id', '!=', False)]</field>
            <field name="context">{}</field>
            <field name="search_view_id" ref="hr_timesheet_report_search"/>
            <field name="view_mode">pivot,graph</field>
            <field name="help" type="html">
              <p class="o_view_nocontent_empty_folder">
                No data yet!
              </p><p>
                Analyze the projects and tasks on which your employees spend their time.<br/>
                Evaluate which part is billable and what costs it represents.
              </p>
            </field>
        </record>

        <record id="timesheet_action_view_report_by_project_pivot" model="ir.actions.act_window.view">
            <field name="sequence" eval="5"/>
            <field name="view_mode">pivot</field>
            <field name="view_id" ref="hr_timesheet.timesheets_analysis_report_pivot_project"/>
            <field name="act_window_id" ref="timesheet_action_report_by_project"/>
        </record>

        <record id="timesheet_action_view_report_by_project_graph" model="ir.actions.act_window.view">
            <field name="sequence" eval="6"/>
            <field name="view_mode">graph</field>
            <field name="view_id" ref="hr_timesheet.timesheets_analysis_report_graph_project"/>
            <field name="act_window_id" ref="timesheet_action_report_by_project"/>
        </record>

        <record id="timesheet_action_view_report_by_project_list" model="ir.actions.act_window.view">
            <field name="sequence" eval="10"/>
            <field name="view_mode">list</field>
            <field name="view_id" ref="hr_timesheet.timesheets_analysis_report_list"/>
            <field name="act_window_id" ref="timesheet_action_report_by_project"/>
        </record>

        <!-- Group by task -->
        <record id="timesheet_action_report_by_task" model="ir.actions.act_window">
            <field name="name">Timesheets by Task</field>
            <field name="res_model">timesheets.analysis.report</field>
            <field name="path">timesheets-by-task</field>
            <field name="domain">[('project_id', '!=', False)]</field>
            <field name="context">{}</field>
            <field name="search_view_id" ref="hr_timesheet_report_search"/>
            <field name="view_mode">pivot,graph</field>
            <field name="help" type="html">
              <p class="o_view_nocontent_empty_folder">
                No data yet!
              </p><p>
                Analyze the projects and tasks on which your employees spend their time.<br/>
                Evaluate which part is billable and what costs it represents.
              </p>
            </field>
        </record>

        <record id="timesheet_action_view_report_by_task_pivot" model="ir.actions.act_window.view">
            <field name="sequence" eval="5"/>
            <field name="view_mode">pivot</field>
            <field name="view_id" ref="hr_timesheet.timesheets_analysis_report_pivot_task"/>
            <field name="act_window_id" ref="timesheet_action_report_by_task"/>
        </record>

        <record id="timesheet_action_view_report_by_task_graph" model="ir.actions.act_window.view">
            <field name="sequence" eval="6"/>
            <field name="view_mode">graph</field>
            <field name="view_id" ref="hr_timesheet.timesheets_analysis_report_graph_task"/>
            <field name="act_window_id" ref="timesheet_action_report_by_task"/>
        </record>

        <record id="timesheet_action_view_report_by_task_list" model="ir.actions.act_window.view">
            <field name="sequence" eval="10"/>
            <field name="view_mode">list</field>
            <field name="view_id" ref="hr_timesheet.timesheets_analysis_report_list"/>
            <field name="act_window_id" ref="timesheet_action_report_by_task"/>
        </record>
    </data>
</odoo>
