<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <!-- Terminology: susu wants the standard Time Off approval actions to
         say "Approve"/"Reject" everywhere, not a mix of "Approve"/"Validate"
         (Odoo's two-step-validation wording) and "Refuse", matching the
         wording already used by this module's own Force Approve/Force
         Reject buttons. Odoo shows "Validate" instead of "Approve" only for
         the first-level approver when a leave type has two-step validation
         enabled; both buttons call the same action_approve method, so
         relabeling "Validate" to "Approve" changes wording only, not
         behaviour. Ribbon badges ("To Validate") and search filter labels
         are left as-is, this only touches the clickable action buttons. -->

    <!-- hr.leave: form header -->
    <record id="view_hr_leave_form_xeno_terminology" model="ir.ui.view">
        <field name="name">hr.leave.form.xeno.terminology</field>
        <field name="model">hr.leave</field>
        <field name="inherit_id" ref="hr_holidays.hr_leave_view_form"/>
        <field name="arch" type="xml">
            <xpath expr="//button[@name='action_approve' and @invisible='not can_validate or can_approve or not id']"
                   position="attributes">
                <attribute name="string">Approve</attribute>
            </xpath>
            <xpath expr="//button[@name='action_refuse']" position="attributes">
                <attribute name="string">Reject</attribute>
            </xpath>
        </field>
    </record>

    <!-- hr.leave: list view (header bulk-action button + per-row buttons) -->
    <record id="view_hr_leave_tree_xeno_terminology" model="ir.ui.view">
        <field name="name">hr.leave.tree.xeno.terminology</field>
        <field name="model">hr.leave</field>
        <field name="inherit_id" ref="hr_holidays.hr_leave_view_tree"/>
        <field name="arch" type="xml">
            <xpath expr="//button[@name='action_approve' and @icon='fa-check']" position="attributes">
                <attribute name="string">Approve</attribute>
            </xpath>
            <!-- header bulk-action button (no invisible attribute) and the
                 per-row button (has invisible) both use icon="fa-times";
                 view inheritance only rewrites the first xpath match, so
                 each needs its own distinguishing predicate. -->
            <xpath expr="//button[@name='action_refuse' and @icon='fa-times' and not(@invisible)]"
                   position="attributes">
                <attribute name="string">Reject</attribute>
            </xpath>
            <xpath expr="//button[@name='action_refuse' and @icon='fa-times' and @invisible]"
                   position="attributes">
                <attribute name="string">Reject</attribute>
            </xpath>
        </field>
    </record>

    <!-- hr.leave: kanban card, desktop layout -->
    <record id="view_hr_leave_kanban_xeno_terminology" model="ir.ui.view">
        <field name="name">hr.leave.kanban.xeno.terminology</field>
        <field name="model">hr.leave</field>
        <field name="inherit_id" ref="hr_holidays.hr_leave_view_kanban"/>
        <field name="arch" type="xml">
            <xpath expr="//button[@name='action_approve' and hasclass('btn-primary')
                                   and not(hasclass('btn-sm'))
                                   and @t-if='record.can_validate.raw_value and !record.can_approve.raw_value']"
                   position="replace">
                <button name="action_approve" type="object" class="btn btn-primary"
                        t-if="record.can_validate.raw_value and !record.can_approve.raw_value">
                    Approve
                </button>
            </xpath>
            <xpath expr="//button[@name='action_refuse' and hasclass('btn-secondary')
                                   and not(hasclass('btn-sm'))
                                   and @t-if='record.can_refuse.raw_value']"
                   position="replace">
                <button name="action_refuse" type="object" class="btn btn-secondary"
                        t-if="record.can_refuse.raw_value">
                    Reject
                </button>
            </xpath>
            <!-- mobile layout -->
            <xpath expr="//button[@name='action_approve' and hasclass('btn-sm', 'btn-primary')
                                   and @t-if='record.can_validate.raw_value and !record.can_approve.raw_value']"
                   position="replace">
                <button t-if="record.can_validate.raw_value and !record.can_approve.raw_value"
                        name="action_approve" type="object" class="btn btn-sm btn-primary py-0"
                        groups="hr_holidays.group_hr_holidays_manager">
                    Approve
                </button>
            </xpath>
            <xpath expr="//button[@name='action_refuse' and hasclass('btn-sm', 'btn-secondary')
                                   and @t-if='record.can_refuse.raw_value']"
                   position="replace">
                <button t-if="record.can_refuse.raw_value"
                        name="action_refuse" type="object" class="btn btn-sm btn-secondary py-0"
                        groups="hr_holidays.group_hr_holidays_user">
                    Reject
                </button>
            </xpath>
        </field>
    </record>

    <!-- hr.leave.allocation: form header -->
    <record id="view_hr_leave_allocation_form_xeno_terminology" model="ir.ui.view">
        <field name="name">hr.leave.allocation.form.xeno.terminology</field>
        <field name="model">hr.leave.allocation</field>
        <field name="inherit_id" ref="hr_holidays.hr_leave_allocation_view_form"/>
        <field name="arch" type="xml">
            <xpath expr="//button[@name='action_approve' and @invisible='not can_validate or can_approve or not id']"
                   position="attributes">
                <attribute name="string">Approve</attribute>
            </xpath>
            <xpath expr="//button[@name='action_refuse']" position="attributes">
                <attribute name="string">Reject</attribute>
            </xpath>
        </field>
    </record>

    <!-- hr.leave.allocation: list view -->
    <record id="view_hr_leave_allocation_tree_xeno_terminology" model="ir.ui.view">
        <field name="name">hr.leave.allocation.tree.xeno.terminology</field>
        <field name="model">hr.leave.allocation</field>
        <field name="inherit_id" ref="hr_holidays.hr_leave_allocation_view_tree"/>
        <field name="arch" type="xml">
            <xpath expr="//button[@name='action_approve' and @icon='fa-check']" position="attributes">
                <attribute name="string">Approve</attribute>
            </xpath>
            <!-- header bulk-action button (no invisible attribute) and the
                 per-row button (has invisible) both use icon="fa-times";
                 view inheritance only rewrites the first xpath match, so
                 each needs its own distinguishing predicate. -->
            <xpath expr="//button[@name='action_refuse' and @icon='fa-times' and not(@invisible)]"
                   position="attributes">
                <attribute name="string">Reject</attribute>
            </xpath>
            <xpath expr="//button[@name='action_refuse' and @icon='fa-times' and @invisible]"
                   position="attributes">
                <attribute name="string">Reject</attribute>
            </xpath>
        </field>
    </record>

    <!-- hr.leave.allocation: kanban card, desktop + mobile layout -->
    <record id="view_hr_leave_allocation_kanban_xeno_terminology" model="ir.ui.view">
        <field name="name">hr.leave.allocation.kanban.xeno.terminology</field>
        <field name="model">hr.leave.allocation</field>
        <field name="inherit_id" ref="hr_holidays.hr_leave_allocation_view_kanban"/>
        <field name="arch" type="xml">
            <xpath expr="//button[@name='action_approve' and hasclass('btn-primary')
                                   and not(hasclass('btn-sm'))
                                   and @t-if='record.can_validate.raw_value and !record.can_approve.raw_value']"
                   position="replace">
                <button name="action_approve" type="object" class="btn btn-primary"
                        t-if="record.can_validate.raw_value and !record.can_approve.raw_value">
                    Approve
                </button>
            </xpath>
            <xpath expr="//button[@name='action_refuse' and hasclass('btn-secondary')
                                   and not(hasclass('btn-sm'))
                                   and @t-if='record.can_refuse.raw_value']"
                   position="replace">
                <button name="action_refuse" type="object" class="btn btn-secondary"
                        t-if="record.can_refuse.raw_value">
                    Reject
                </button>
            </xpath>
            <!-- mobile layout -->
            <xpath expr="//button[@name='action_approve' and hasclass('btn-sm', 'btn-primary')
                                   and @t-if='record.can_validate.raw_value and !record.can_approve.raw_value']"
                   position="replace">
                <button name="action_approve" type="object" class="btn btn-sm btn-primary py-0"
                        t-if="record.can_validate.raw_value and !record.can_approve.raw_value">
                    Approve
                </button>
            </xpath>
            <xpath expr="//button[@name='action_refuse' and hasclass('btn-sm', 'btn-secondary')
                                   and @t-if='record.can_refuse.raw_value']"
                   position="replace">
                <button name="action_refuse" type="object" class="btn btn-sm btn-secondary py-0"
                        t-if="record.can_refuse.raw_value">
                    Reject
                </button>
            </xpath>
        </field>
    </record>

    <!-- The dialog opened for an existing leave (e.g. clicking an event on
         the Time Off calendar) shows this action's own name as its title
         rather than the record's: "Time Off Request" becomes "Leave
         Request", matching the rest of this module's terminology. -->
    <record id="hr_holidays.hr_leave_action_my_request" model="ir.actions.act_window">
        <field name="name">Leave Request</field>
    </record>

    <!-- Company-terminology wording pass: susu wants the native Time Off
         app's labels to say "Leave(s)" throughout, not "Time Off", and
         "Leave Balance(s)" instead of "Allocation(s)". Both the action
         names (which surface in breadcrumbs/dialog titles even when a
         menuitem overrides its own display label) and the menuitems and
         filters themselves are covered below. -->
    <record id="hr_holidays.menu_hr_holidays_root" model="ir.ui.menu">
        <field name="name">Leaves</field>
    </record>
    <record id="hr_holidays.hr_leave_action_my" model="ir.actions.act_window">
        <field name="name">My Leaves</field>
    </record>
    <!-- hr_leave_menu_my has no explicit name of its own in core, so its
         display label was computed once from the action's name at
         hr_holidays' own install time and stored directly on this
         ir.ui.menu record. Overriding the action's name field above does
         NOT retroactively refresh that already-stored value, so the
         sidebar kept showing "My Time Off" even after the action itself
         became "My Leaves" (menu_open_allocation below needs no such fix
         since core happens to give it an explicit name of its own). -->
    <record id="hr_holidays.hr_leave_menu_my" model="ir.ui.menu">
        <field name="name">My Leaves</field>
    </record>
    <record id="hr_holidays.menu_open_allocation" model="ir.ui.menu">
        <field name="name">My Leave Balance</field>
    </record>
    <record id="hr_holidays.hr_leave_allocation_action_my" model="ir.actions.act_window">
        <field name="name">My Leave Balance</field>
    </record>
    <record id="hr_holidays.menu_open_department_leave_approve" model="ir.ui.menu">
        <field name="name">Leaves</field>
    </record>
    <record id="hr_holidays.hr_leave_action_action_approve_department" model="ir.actions.act_window">
        <field name="name">All Leaves</field>
    </record>
    <record id="hr_holidays.hr_holidays_menu_manager_approve_allocations" model="ir.ui.menu">
        <field name="name">Leave Balances</field>
    </record>
    <record id="hr_holidays.hr_leave_allocation_action_approve_department" model="ir.actions.act_window">
        <field name="name">Leave Balances</field>
    </record>

    <!-- susu (2026-07-20): "Overview" under Leaves currently has no group
         restriction at all (visible to literally everyone). Gate it to
         the same Officer/Administrator tier as the other management-only
         entries above (Leaves/Leave Balances), so a regular employee's
         Leaves tab only shows their own self-service items (My Leaves,
         New Request, My Leave Balance). -->
    <record id="hr_holidays.menu_hr_holidays_dashboard" model="ir.ui.menu">
        <field name="group_ids" eval="[(6, 0, [ref('hr_holidays.group_hr_holidays_user'), ref('hr_holidays.group_hr_holidays_manager')])]"/>
    </record>

    <record id="view_hr_holidays_filter_xeno_terminology" model="ir.ui.view">
        <field name="name">hr.holidays.filter.xeno.terminology</field>
        <field name="model">hr.leave</field>
        <field name="inherit_id" ref="hr_holidays.view_hr_holidays_filter"/>
        <field name="arch" type="xml">
            <filter name="my_leaves" position="attributes">
                <attribute name="string">My Leaves</attribute>
            </filter>
        </field>
    </record>
    <record id="view_hr_leave_allocation_filter_xeno_terminology" model="ir.ui.view">
        <field name="name">hr.leave.allocation.filter.xeno.terminology</field>
        <field name="model">hr.leave.allocation</field>
        <field name="inherit_id" ref="hr_holidays.view_hr_leave_allocation_filter"/>
        <field name="arch" type="xml">
            <filter name="my_leaves" position="attributes">
                <attribute name="string">My Leave Balance</attribute>
            </filter>
        </field>
    </record>

    <!-- "Time Off Type" -> "Leave Type": the holiday_status_id field
         label on both hr.leave and hr.leave.allocation (core's own
         string=, not touched by anything else in this module). -->
    <record id="view_hr_leave_form_xeno_type_label" model="ir.ui.view">
        <field name="name">hr.leave.form.xeno.type.label</field>
        <field name="model">hr.leave</field>
        <field name="inherit_id" ref="hr_holidays.hr_leave_view_form"/>
        <field name="arch" type="xml">
            <field name="holiday_status_id" position="attributes">
                <attribute name="string">Leave Type</attribute>
            </field>
        </field>
    </record>
    <record id="view_hr_leave_tree_xeno_type_label" model="ir.ui.view">
        <field name="name">hr.leave.tree.xeno.type.label</field>
        <field name="model">hr.leave</field>
        <field name="inherit_id" ref="hr_holidays.hr_leave_view_tree"/>
        <field name="arch" type="xml">
            <field name="holiday_status_id" position="attributes">
                <attribute name="string">Leave Type</attribute>
            </field>
        </field>
    </record>
    <record id="view_hr_leave_allocation_form_xeno_type_label" model="ir.ui.view">
        <field name="name">hr.leave.allocation.form.xeno.type.label</field>
        <field name="model">hr.leave.allocation</field>
        <field name="inherit_id" ref="hr_holidays.hr_leave_allocation_view_form"/>
        <field name="arch" type="xml">
            <field name="holiday_status_id" position="attributes">
                <attribute name="string">Leave Type</attribute>
            </field>
        </field>
    </record>
    <record id="view_hr_leave_allocation_tree_xeno_type_label" model="ir.ui.view">
        <field name="name">hr.leave.allocation.tree.xeno.type.label</field>
        <field name="model">hr.leave.allocation</field>
        <field name="inherit_id" ref="hr_holidays.hr_leave_allocation_view_tree"/>
        <field name="arch" type="xml">
            <field name="holiday_status_id" position="attributes">
                <attribute name="string">Leave Type</attribute>
            </field>
        </field>
    </record>
</odoo>
