<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <!-- Partner form view -->
    <record id="view_shift_form_inherit" model="ir.ui.view">
        <field name="name">view.shift.shift.form.inherit</field>
        <field name="model">shift.shift</field>
        <field name="inherit_id" ref="coop_shift.view_shift_form"/>
        <field name="arch" type="xml">
            <field name="state" position="attributes">
                <attribute name="statusbar_visible">draft,confirm,entry,done</attribute>
            </field>
            <button name="button_done" position="attributes">
                <attribute name="states">entry</attribute>
            </button>
            <button name="button_done" position="after">
                <button name="button_makeupok" type="object" states="confirm"
                        class="oe_highlight" string="Make-ups OK"/>
            </button>
            <field name="date_end" position="after">
                <field name="is_send_reminder" group="base.group_no_one" readonly="1" />
            </field>
        </field>
    </record>

    <!-- Partner form view -->
    <record id="view_shift_form_attendance_entry" model="ir.ui.view">
        <field name="name">view.shift.shift.form.inherit</field>
        <field name="model">shift.shift</field>
        <field name="inherit_id" ref="coop_shift.view_shift_form"/>
        <field name="mode">primary</field>
        <field name="arch" type="xml">

            <!-- Hiding header fields -->
            <field name="shift_template_id" position="attributes">
                <attribute name="invisible">1</attribute></field>
            <field name="shift_type_id" position="attributes">
                <attribute name="invisible">1</attribute>
            </field>
            <group name="datetime" position="attributes">
                <attribute name="invisible">1</attribute>
            </group>

            <!-- Hiding Smart Button Attendees-->
            <button name="%(coop_shift.act_shift_registration_from_shift)d" position="attributes">
                <attribute name="invisible">1</attribute>
            </button>

            <!-- Hiding Shift Tabs -->
            <page name="registrations" position="attributes">
                <attribute name="invisible">1</attribute>
            </page>

            <!-- Adding new Tabs for Standard and FTOP -->
            <page name="registrations" position="before">
                <page name="participants_list" string="Attendees">
                    <field name="registration_ids" context="{'is_standard_ticket': True, 'default_shift_id': active_id, 'tree_view_ref' : 'coop_membership.view_shift_registration_tree_confirm_one2many'}"/>
                </page>
            </page>

            <!-- Set Readonly for Shift Name, Shift Leaders and Location for status <> Unconfirmed -->
            <field name="name" position="attributes">
                <attribute name="attrs">{'readonly': [('state', '!=', 'draft')]}</attribute>
            </field>

            <field name="user_ids" position="attributes">
                <attribute name="attrs">{'readonly': [('state', '!=', 'draft')]}</attribute>
                <attribute name="groups">coop_shift.group_shift_user,coop_membership.group_membership_access_user</attribute>
            </field>

            <button name="button_confirm" position="attributes">
                <attribute name="groups">coop_membership.group_employee_native_menu</attribute>
            </button>
            <button name="button_draft" position="attributes">
                <attribute name="groups">coop_membership.group_employee_native_menu</attribute>
            </button>

            <xpath expr="//div[@class='oe_title']" position="attributes">
                <attribute name="groups">coop_shift.group_shift_user,
                    coop_membership.group_membership_access_user,
                    coop_membership.group_membership_bdm_saisie
                </attribute>
            </xpath>
            <xpath expr="//div[@name='button_box']" position="after">
                <div class="oe_title" groups="coop_membership.group_membership_bdm_presence">
                    <label for="shift_name_read" class="oe_edit_only"/>
                    <h1><field name="shift_name_read"
                               attrs="{'readonly': True}"
                               placeholder="Shift Name"/></h1>
                </div>
            </xpath>
        </field>
    </record>

    <record model="ir.ui.view" id="view_shift_search_inherit">
        <field name="name">shift.shift.search.inherit</field>
        <field name="model">shift.shift</field>
        <field name="inherit_id" ref="coop_shift.view_shift_search"/>
        <field name="arch" type="xml">
            <filter name="confirmed" position="after">
                <filter string="Entry" name="entry" domain="[('state','=','entry')]"
                        help="Entry shift"/>
            </filter>
        </field>
    </record>

    <record model="ir.actions.act_window" id="action_shift_attendance_entry_view">
       <field name="name">Attendance Entry</field>
       <field name="type">ir.actions.act_window</field>
       <field name="res_model">shift.shift</field>
       <field name="view_type">form</field>
       <field name="view_mode">tree,form</field>
       <field name="context">{"search_default_confirmed": 1}</field>
       <field name="search_view_id" ref="coop_shift.view_shift_search"/>
    </record>

    <record id="coop_shift.action_timesheet_wizard" model="ir.actions.act_window">
        <field name="groups_id" eval="[(6, 0, [
            ref('coop_membership.group_membership_access_user'),
            ref('coop_shift.group_shift_user')
            ])]"/>
    </record>
</odoo>