<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2019 Tecnativa - Jairo Llopis
     License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<data>
    <!-- Wizard view to resume work -->
    <record id="hr_timesheet_switch_form" model="ir.ui.view">
        <field name="name">hr.timesheet.switch resume form</field>
        <field name="model">hr.timesheet.switch</field>
        <!-- For resetting the value coming from previous version -->
        <field name="inherit_id" />
        <field name="arch" type="xml">
            <form>
                <sheet>
                    <div class="oe_title" modifiers="{}">
                        <label class="oe_edit_only" for="name" />
                        <h1>
                            <field name="name" />
                        </h1>
                    </div>
                    <group colspan="4">
                        <field name="date_time" />
                        <field name="date_time_end" />
                        <field name="project_id" required="1" />
                        <field name="task_id" />
                        <field name="company_id" groups="base.group_multi_company" />
                        <field name="company_id" invisible="1" />
                    </group>
                    <group
                        name="messages"
                        string="Previous timer"
                        attrs="{'invisible': [('running_timer_id', '=', False)]}"
                        col="4"
                    >
                        <p colspan="4">
                            You have a running timer called
                            <field
                                name="running_timer_id"
                                class="oe_inline"
                                context="{'form_view_ref': 'hr_timesheet.hr_timesheet_line_form'}"
                            />
                            and started at
                            <field name="running_timer_start" class="oe_inline" />
                            .
                            If you continue, it will be stopped with
                            <strong>
                                <field
                                    name="running_timer_duration"
                                    class="oe_inline text-info"
                                    widget="float_time"
                                    attrs="{'invisible': [('running_timer_duration', '&gt;=', 5)]}"
                                />
                                <field
                                    name="running_timer_duration"
                                    class="oe_inline text-warning"
                                    widget="float_time"
                                    attrs="{'invisible': [('running_timer_duration', '&lt;', 5)]}"
                                />
                                hour(s).
                            </strong>
                        </p>
                        <div
                            class="alert alert-warning"
                            colspan="4"
                            role="alert"
                            attrs="{'invisible': [('running_timer_duration', '&lt;', 5)]}"
                        >
                            That is a lot of time! Make sure it is fine before saving.
                        </div>
                    </group>
                </sheet>
                <!-- Footer buttons -->
                <footer>
                    <button
                        name="action_switch"
                        type="object"
                        attrs="{'invisible': [('running_timer_id', '!=', False)]}"
                        string="Start new timer"
                        class="oe_highlight"
                    />
                    <button
                        name="action_switch"
                        type="object"
                        attrs="{'invisible': ['|', ('running_timer_id', '=', False), ('running_timer_duration', '&gt;=', 5)]}"
                        string="Stop previous timer and start the new one"
                        class="oe_highlight"
                    />
                    <button
                        name="action_switch"
                        confirm="The previous timer is old. Do you really want to stop it now?"
                        type="object"
                        attrs="{'invisible': ['|', ('running_timer_id', '=', False), ('running_timer_duration', '&lt;', 5)]}"
                        string="Stop that very old timer and start the new one"
                        class="btn-warning"
                    />
                    <button special="cancel" string="Cancel" />
                </footer>
            </form>
        </field>
    </record>
    <record id="hr_timesheet_switch_action" model="ir.actions.act_window">
        <field name="name">Start work</field>
        <field name="res_model">hr.timesheet.switch</field>
        <field name="target">new</field>
        <field name="view_mode">form</field>
        <field name="binding_view_types">form</field>
        <field name="context">{'show_created_timer': True}</field>
    </record>
    <menuitem
        id="hr_timesheet_switch_menu"
        name="Start work"
        action="hr_timesheet_switch_action"
        parent="hr_timesheet.menu_hr_time_tracking"
        groups="hr_timesheet.group_hr_timesheet_user"
        sequence="10"
    />
</data>
