<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <record id="view_hr_business_trip_wizard_form" model="ir.ui.view">
            <field name="name">hr.business.trip.wizard.form</field>
            <field name="model">hr.business.trip.wizard</field>
            <field name="arch" type="xml">
                <form string="New Business Trip (HR)">
                    <sheet>
                        <div class="alert alert-info" role="alert">
                            Created directly by HR: each selected employee gets their own
                            Business Trip request, already Acknowledged (no Submit/HR
                            acknowledgment step needed).
                        </div>
                        <group>
                            <field name="employee_ids" widget="many2many_tags" options="{'no_create': True}"/>
                        </group>
                        <group>
                            <group string="Trip">
                                <field name="date_from"/>
                                <field name="date_to"/>
                                <field name="trip_type"/>
                                <field name="trip_type_other"
                                       invisible="trip_type != 'others'"
                                       required="trip_type == 'others'"/>
                            </group>
                            <group string="Location">
                                <field name="address"/>
                                <field name="city"/>
                                <field name="country_id" options="{'no_create': True}"/>
                            </group>
                        </group>
                        <group string="Reason">
                            <field name="reason" nolabel="1" colspan="2"/>
                        </group>
                        <group string="Requirements">
                            <field name="requirements_description" nolabel="1" colspan="2"/>
                        </group>
                        <group string="Remark">
                            <field name="remark" nolabel="1" colspan="2"/>
                        </group>
                    </sheet>
                    <footer>
                        <button name="action_create" type="object" string="Create &amp; Acknowledge"
                                class="btn-primary"/>
                        <button string="Cancel" special="cancel" class="btn-secondary"/>
                    </footer>
                </form>
            </field>
        </record>

        <record id="action_hr_business_trip_wizard" model="ir.actions.act_window">
            <field name="name">New Business Trip (HR)</field>
            <field name="res_model">hr.business.trip.wizard</field>
            <field name="view_mode">form</field>
            <field name="view_id" ref="view_hr_business_trip_wizard_form"/>
            <field name="target">new</field>
        </record>

        <!-- HR-facing "all records" list: unlike the self-service "Business
             Trips"/"Business Trip Approvals" actions (xeno_attendance,
             scoped to own-record or non-draft), this shows literally every
             request including Drafts, so HR has one place to see the whole
             picture. Uses xeno_attendance's own list/form views unchanged
             (native single-employee "New" stays available, e.g. for
             building a single Draft the normal Submit -> Acknowledge way),
             plus the bound server action below for bulk multi-employee
             creation. -->
        <record id="action_hr_business_trip_all" model="ir.actions.act_window">
            <field name="name">Business Trip</field>
            <field name="res_model">hr.business.trip</field>
            <field name="view_mode">list,form</field>
            <field name="domain">[]</field>
            <field name="search_view_id" ref="xeno_attendance.view_hr_business_trip_search"/>
            <field name="context">{'search_default_pending': 1}</field>
        </record>

        <!-- Confirmed live: Odoo's list-view "Actions" (gear) toolbar only
             renders once at least one row is selected, so there's no native
             way to bind a list-level action reachable with zero rows
             selected/existing (and a plain form button can't open this
             instead, either: Odoo always tries to save the current record
             before running ANY button, which fails here on a blank Draft's
             empty required fields, confirmed live). On a genuinely empty
             table, HR creates the very first request via the normal "New"
             button (single employee); from then on, this bulk action is
             one click away (select any row, Actions > New Business Trip
             (Select Employees)), regardless of which/how many rows are
             checked: the code below ignores the selection entirely and
             always opens a blank multi-employee picker. -->
        <record id="action_server_hr_business_trip_new_hr" model="ir.actions.server">
            <field name="name">New Business Trip (Select Employees)</field>
            <field name="model_id" ref="xeno_attendance.model_hr_business_trip"/>
            <field name="binding_model_id" ref="xeno_attendance.model_hr_business_trip"/>
            <field name="binding_view_types">list</field>
            <field name="state">code</field>
            <field name="code">action = env["ir.actions.act_window"]._for_xml_id("xeno_leave.action_hr_business_trip_wizard")</field>
        </record>
    </data>
    <data noupdate="1">
        <menuitem id="menu_hr_business_trip_hr_all"
                  name="Business Trip"
                  parent="menu_xeno_hr_attendance"
                  action="action_hr_business_trip_all"
                  groups="hr.group_hr_user"
                  sequence="5"/>
    </data>
</odoo>
