<?xml version="1.0" ?>
<odoo>
    <record id="reservation_wizard" model="ir.ui.view">
        <field name="name">Split, join or swap reservations</field>
        <field name="model">pms.reservation.split.join.swap.wizard</field>
        <field name="arch" type="xml">
            <form>
                <div class="row">
                    <div class="col-3">
                        <label for="operation" class="font-weight-bold" />
                        <br />
                        <field name="operation" widget="radio" />
                        <field name="allowed_rooms_sources" invisible="1" />
                        <field name="allowed_rooms_target" invisible="1" />
                    </div>
                    <div class="col-5">
                        <span attrs="{'invisible': [('operation','=','swap')]}">
                            <label for="reservation_id" /> <br />
                            <field name="reservation_id" readonly="1" /><br />
                        </span>
                        <span attrs="{'invisible': [('operation','!=','swap')]}">
                            <div class="row">
                                <div class="col-6">
                                    <label for="checkin" /> <br />
                                    <field
                                        name="checkin"
                                        widget="daterange"
                                        options="{'related_end_date': 'checkout'}"
                                    /><br />
                                    <label for="checkout" /> <br />
                                    <field
                                        name="checkout"
                                        widget="daterange"
                                        options="{'related_start_date': 'checkin'}"
                                    /><br />
                                </div>
                            </div>
                        </span>
                    </div>
                    <div class="col-4">
                        <div>
                            <span attrs="{'invisible': [('operation','!=','swap')]}">
                                <label for="room_source" />
                                <br />
                                <field name="room_source" />
                                <br />
                            </span>
                            <label
                                attrs="{'invisible': [('operation','!=','swap')]}"
                                for="room_target"
                            />
                            <label
                                attrs="{'invisible': [('operation','!=','join')]}"
                                for="room_target"
                                string="Room"
                            />
                            <br />
                            <field
                                name="room_target"
                                attrs="{'invisible': [('operation','=','split')]}"
                            />

                        </div>
                    </div>
                    <div
                        class="col-12"
                        attrs="{'invisible': [('operation','!=','swap')]}"
                    >
                        <field name="reservation_ids" nolabel="1" readonly="1">
                            <tree>
                                <field string="Reservation" name="name" />
                                <field name="checkin" />
                                <field name="checkout" />
                                <field name="rooms" />
                            </tree>
                        </field>
                    </div>
                    <div
                        class="col-12"
                        attrs="{'invisible': [('operation','!=','split')]}"
                    >
                        <field
                            name="reservation_lines_to_change"
                            nolabel="1"
                            default_order="rooms"
                        >
                            <tree editable="bottom" create="false" delete="false">
                                <field name="reservation_wizard_id" invisible="1" />
                                <field name="allowed_room_ids" invisible="1" />
                                <field name="date" readonly="0" />
                                <field
                                    name="room_id"
                                    domain="[('id', 'in', allowed_room_ids)]"
                                />
                            </tree>
                        </field>
                    </div>
                </div>
                <footer class="text-right">
                    <button string="Cancel" class="oe_link border" special="cancel" />
                    or
                    <button
                        name="action_join"
                        attrs="{'invisible': [('operation','!=','join')]}"
                        string="Join reservation"
                        type="object"
                        class="oe_highlight"
                    />
                    <button
                        name="action_split"
                        attrs="{'invisible': [('operation','!=','split')]}"
                        string="Split reservation"
                        type="object"
                        class="oe_highlight"
                    />
                    <button
                        name="action_swap"
                        attrs="{'invisible': [('operation','!=','swap')]}"
                        string="Swap reservation rooms"
                        type="object"
                        class="oe_highlight"
                    />
                </footer>
            </form>
        </field>
    </record>
</odoo>
