<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <!-- Seed rows for the "Leave Validations" page. `enabled` is deliberately
         NOT set on any record, so a module upgrade refreshes labels/text
         while leaving each rule's on/off state exactly as the administrator
         last set it (enabled defaults True only on first creation). -->

    <!-- ============ Toggleable policies (owned by this system) ============ -->
    <record id="leave_validation_rule_timing" model="xeno.leave.validation.rule">
        <field name="code">timing</field>
        <field name="name">Advance notice &amp; backdating limits</field>
        <field name="category">submission</field>
        <field name="kind">toggle</field>
        <field name="sequence">10</field>
        <field name="manage_hint">Thresholds per type: Leave Types &gt; Request Timing Limits</field>
        <field name="description">A request must respect the leave type's Advance Notice (earliest start = today + N days) or, failing that, its Max Backdate (earliest start = today - N days); with neither set, the start date must be today or later. Skipped when HR creates a request on another employee's behalf.</field>
    </record>

    <record id="leave_validation_rule_weekend_dates" model="xeno.leave.validation.rule">
        <field name="code">weekend_dates</field>
        <field name="name">No weekend start/end dates</field>
        <field name="category">submission</field>
        <field name="kind">toggle</field>
        <field name="sequence">15</field>
        <field name="description">The company is closed Saturday/Sunday, so a request whose start or end date falls on a weekend is blocked with an alert naming the date -- almost always an accidental date-picker mis-click. A multi-day request that merely spans a weekend in the middle (e.g. Friday to Monday) is unaffected.</field>
    </record>

    <record id="leave_validation_rule_holiday_dates" model="xeno.leave.validation.rule">
        <field name="code">holiday_dates</field>
        <field name="name">No leave start/end dates on a declared holiday</field>
        <field name="category">submission</field>
        <field name="kind">toggle</field>
        <field name="sequence">17</field>
        <field name="manage_hint">Holidays are managed under Holidays &gt; Holiday Calendar</field>
        <field name="description">A declared public/company holiday is already a non-working day, so a request whose start or end date falls on one is blocked with an alert naming the date -- almost always an accidental date-picker mis-click. A multi-day request that merely spans a holiday in the middle is unaffected. HR can still create a genuine Holiday Deduction on the employee's behalf.</field>
    </record>

    <record id="leave_validation_rule_overlap" model="xeno.leave.validation.rule">
        <field name="code">overlap</field>
        <field name="name">Block overlapping leave requests</field>
        <field name="category">submission</field>
        <field name="kind">toggle</field>
        <field name="sequence">20</field>
        <field name="description">An employee cannot have two requests covering the same day(s) unless the earlier one is already Cancelled or Rejected. A hard block (Odoo core only shows a soft warning).</field>
    </record>

    <record id="leave_validation_rule_activity_restricted_dates" model="xeno.leave.validation.rule">
        <field name="code">activity_restricted_dates</field>
        <field name="name">No leave on restricted activity days</field>
        <field name="category">submission</field>
        <field name="kind">toggle</field>
        <field name="sequence">25</field>
        <field name="manage_hint">Tick per activity: Company Activities &gt; Restrict Leave on These Dates</field>
        <field name="description">A request is blocked if its dates overlap a Company Activity marked "Restrict Leave on These Dates" (e.g. a mandatory Guest Visit day). This is not an in-system emergency override -- a genuine emergency must go through HR directly, who can still create the leave on the employee's behalf (the same on-behalf paths this rule already exempts).</field>
    </record>

    <record id="leave_validation_rule_part_time_hours" model="xeno.leave.validation.rule">
        <field name="code">part_time_hours</field>
        <field name="name">Part-time hours within working schedule</field>
        <field name="category">submission</field>
        <field name="kind">toggle</field>
        <field name="sequence">30</field>
        <field name="description">For a Part-time Leave, end time must be after start time, the chosen clock range must sit within the employee's scheduled working span for that weekday, and must not fall entirely inside a non-working period (e.g. the lunch break).</field>
    </record>

    <record id="leave_validation_rule_locked_fields" model="xeno.leave.validation.rule">
        <field name="code">locked_fields</field>
        <field name="name">Lock submitted request from employee edits</field>
        <field name="category">editing</field>
        <field name="kind">toggle</field>
        <field name="sequence">40</field>
        <field name="description">Once submitted, an employee can no longer edit a request's content (type/dates/reason/duration) -- only Cancel it or ask HR to update it. HR/administrators are unaffected.</field>
    </record>

    <record id="leave_validation_rule_prorated_balance" model="xeno.leave.validation.rule">
        <field name="code">prorated_balance</field>
        <field name="name">Pro-rated monthly balance</field>
        <field name="category">balance</field>
        <field name="kind">toggle</field>
        <field name="sequence">45</field>
        <field name="manage_hint">Mark each type: Leave Types &gt; Request Timing Limits &gt; Pro-rated Monthly Accrual</field>
        <field name="description">For leave types marked Pro-rated Monthly Accrual, a self-service request is checked against the amount accrued up to the request's month (yearly allocation / 12 x month number) minus what's already used/booked this year. Requests beyond the pro-rated entitlement are blocked, and the message suggests alternative leave types the employee still has balance in. Skipped when HR creates a request on someone else's behalf.</field>
    </record>

    <!-- ============ Configured per Leave Type ============ -->
    <record id="leave_validation_rule_validation_type" model="xeno.leave.validation.rule">
        <field name="code">validation_type</field>
        <field name="name">Approval routing (who must approve)</field>
        <field name="category">approval</field>
        <field name="kind">per_type</field>
        <field name="sequence">50</field>
        <field name="manage_hint">Leave Types &gt; Approval: None / By Leave Approver / By Employee's Approver / Both</field>
        <field name="description">Each leave type decides who must approve a request: nobody, the employee's approver (manager), a Leave Approver (HR), or both.</field>
    </record>

    <!-- ============ Always enforced (Odoo core / chain integrity) ======== -->
    <record id="leave_validation_rule_approver_restriction" model="xeno.leave.validation.rule">
        <field name="code">approver_restriction</field>
        <field name="name">Only the configured approver can decide (never self)</field>
        <field name="category">approval</field>
        <field name="kind">core</field>
        <field name="sequence">60</field>
        <field name="manage_hint">Steps per department/employee: Configuration &gt; Leave Approvers</field>
        <field name="description">Approve/Reject act on the current step of the approval chain: a named approver must match exactly, a blank step needs a Time Off Officer, and no one can approve or reject their own leave. An integrity guarantee of the approval chain -- not switchable.</field>
    </record>

    <record id="leave_validation_rule_allocation_balance" model="xeno.leave.validation.rule">
        <field name="code">allocation_balance</field>
        <field name="name">Sufficient allocation balance &amp; validity</field>
        <field name="category">balance</field>
        <field name="kind">core</field>
        <field name="sequence">70</field>
        <field name="description">For allocation-based leave types, the employee must hold an allocation with enough remaining days whose validity window covers the requested dates. Enforced by Odoo core.</field>
    </record>

    <record id="leave_validation_rule_contract_coverage" model="xeno.leave.validation.rule">
        <field name="code">contract_coverage</field>
        <field name="name">Dates covered by employee contract</field>
        <field name="category">submission</field>
        <field name="kind">core</field>
        <field name="sequence">80</field>
        <field name="description">Requested dates must fall within the employee's running contract, where contracts apply. Enforced by Odoo core.</field>
    </record>

    <record id="leave_validation_rule_mandatory_day" model="xeno.leave.validation.rule">
        <field name="code">mandatory_day</field>
        <field name="name">No leave on Mandatory Days</field>
        <field name="category">submission</field>
        <field name="kind">core</field>
        <field name="sequence">90</field>
        <field name="description">Time off cannot be requested on a company Mandatory Day. Enforced by Odoo core.</field>
    </record>

    <record id="leave_validation_rule_date_consistency" model="xeno.leave.validation.rule">
        <field name="code">date_consistency</field>
        <field name="name">Valid dates &amp; allowed state transitions</field>
        <field name="category">editing</field>
        <field name="kind">core</field>
        <field name="sequence">100</field>
        <field name="description">The date range must be valid and non-zero in duration, and edits are only allowed in states where Odoo permits them. Enforced by Odoo core.</field>
    </record>
</odoo>
