from odoo import fields, models


class HrLeaveType(models.Model):
    _inherit = "hr.leave.type"

    # Terminology: this deployment says "Leave approver", not core's
    # "Time Off Officer". Redefining the selection relabels the options
    # shown on the Leave Types form (leave_validation_type) without
    # changing their stored keys or any behaviour.
    leave_validation_type = fields.Selection(
        selection=[
            ("no_validation", "None needed"),
            ("hr", "By Leave Approver"),
            ("manager", "By Employee's Approver"),
            ("both", "By Employee's Approver and Leave Approver"),
        ],
    )

    xeno_advance_days = fields.Integer(
        string="Advance Notice (days)", default=0,
        help="Minimum number of days before the start date this leave type "
             "must be requested. 0 = no minimum. Mirrors XENHR's "
             "leave_types.advance_days -- e.g. Annual Leave requires 7 "
             "days' notice there.",
    )
    xeno_max_backdate_days = fields.Integer(
        string="Max Backdate (days)", default=0,
        help="How many days in the past this leave type may be backdated "
             "when requested. 0 = none (start date must be today or later, "
             "unless Advance Notice above applies instead). Mirrors "
             "XENHR's leave_types.max_backdate_days -- e.g. Sick Leave "
             "allows 3 days there. Advance Notice takes priority over this "
             "if both are set on the same type.",
    )
    xeno_flexible_duration = fields.Boolean(
        string="Flexible Duration (Day/Half-Day/Hour)", default=False,
        help="If enabled, the requester picks Day/Half-Day/Hour per "
             "request (hr.leave.xeno_request_unit) instead of this type "
             "having one fixed Duration Type. Mirrors XENHR's model, "
             "where a leave type can have several leave_base_types "
             "(Full-day/Part-time/First-half/Second-half) at once.",
    )
    xeno_prorated = fields.Boolean(
        string="Pro-rated Monthly Accrual", default=False,
        help="If enabled, this type's yearly allocation is treated as "
             "accruing evenly month by month (yearly total / 12 per month). "
             "A self-service request is then checked against the amount "
             "accrued up to the request's month minus what's already been "
             "used/booked this year -- blocking requests beyond the "
             "pro-rated entitlement (see the 'Pro-rated balance' rule on the "
             "Leave Validations page). Leave the yearly allocation as usual; "
             "this only changes how much of it is available each month. "
             "Typically on Personal Leave, not on types granted in full up "
             "front.",
    )
    xeno_detail = fields.Html(
        string="Detail",
        help="Entitlement/procedure detail shown to employees on the Apply "
             "for Leave form as soon as they pick this Leave Type -- e.g. "
             "for Maternity Leave, explain the 60 unpaid + 60 paid day "
             "split and whether weekends/holidays count against those 60 "
             "days. Purely informational, not enforced by the system.",
    )
