<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2018-2019 Tecnativa - Pedro M. Baeza
     License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
    <record id="hr_attendance_theoretical_view_filter" model="ir.ui.view">
        <field name="model">hr.attendance.theoretical.time.report</field>
        <field name="arch" type="xml">
            <search>
                <field name="employee_id" />
                <filter
                    name="today"
                    string="Today"
                    domain="[('date', '=', datetime.date.today().strftime('%Y-%m-%d'))]"
                />
                <filter
                    name="previous_month"
                    string="Previous Month"
                    domain="[('date', '&gt;=', (datetime.date.today() - relativedelta(months=1)).strftime('%Y-%m-01')), ('date', '&lt;', datetime.date.today().strftime('%Y-%m-01'))]"
                />
                <filter
                    name="current_month"
                    string="Current Month"
                    domain="[('date', '&gt;=', datetime.date.today().strftime('%Y-%m-01'))]"
                />
                <filter
                    name="current_year"
                    string="Current Year"
                    domain="[('date', '&gt;=', datetime.date.today().strftime('%Y-01-01'))]"
                />
                <separator />
                <filter
                    name="my"
                    string="My Attendances"
                    domain="[('employee_id.user_id.id', '=', uid)]"
                />
                <separator />
                <filter
                    name="active_employees"
                    string="Active employees"
                    domain="[('employee_id.active', '=', True)]"
                />
            </search>
        </field>
    </record>
    <record id="hr_attendance_theoretical_view_pivot" model="ir.ui.view">
        <field name="model">hr.attendance.theoretical.time.report</field>
        <field name="arch" type="xml">
            <pivot disable_linking="1">
                <field name="employee_id" type="row" />
                <field name="department_id" />
                <field name="date" type="col" />
                <field name="worked_hours" type="measure" widget="float_time" />
                <field name="theoretical_hours" type="measure" widget="float_time" />
                <field name="difference" type="measure" widget="float_time" />
            </pivot>
        </field>
    </record>
    <record id="hr_attendance_theoretical_view_graph" model="ir.ui.view">
        <field name="model">hr.attendance.theoretical.time.report</field>
        <field name="arch" type="xml">
            <graph>
                <field name="employee_id" />
                <field name="department_id" />
                <field name="date" />
                <field name="theoretical_hours" type="measure" />
            </graph>
        </field>
    </record>
    <record id="hr_attendance_theoretical_action" model="ir.actions.act_window">
        <field name="name">Theoretical vs Attended Time Analysis</field>
        <field name="res_model">hr.attendance.theoretical.time.report</field>
        <field
            name="context"
        >{'search_default_previous_month': 1, 'search_default_current_month': 1, 'search_default_my': 1}</field>
        <field name="view_mode">pivot,graph</field>
    </record>
    <record id="hr_attendance.menu_hr_attendance_report" model="ir.ui.menu">
        <field
            name="groups_id"
            eval="[(4, ref('hr_attendance.group_hr_attendance'))]"
        />
        <!-- We need to leave the action empty for consistency because we are going
            to set different submenus, otherwise the Reports menu would not be
            displayed to a basic user. !-->
        <field name="action" eval="False" />
    </record>
    <menuitem
        id="menu_hr_attendance_report"
        name="Attendances Analysis"
        parent="hr_attendance.menu_hr_attendance_report"
        sequence="10"
        groups="hr_attendance.group_hr_attendance_user"
        action="hr_attendance.hr_attendance_report_action"
    />
    <menuitem
        id="menu_hr_attendance_theoretical_root"
        name="Theoretical vs Attended Time"
        parent="hr_attendance.menu_hr_attendance_report"
        sequence="15"
        groups="hr_attendance.group_hr_attendance"
    />
    <menuitem
        id="menu_hr_attendance_theoretical_report"
        name="Analysis"
        action="hr_attendance_theoretical_action"
        parent="menu_hr_attendance_theoretical_root"
        groups="hr_attendance.group_hr_attendance"
        sequence="20"
    />
</odoo>
