<?xml version="1.0"?>
<odoo>

    <record id="hotel_reservation_view_form" model="ir.ui.view">
        <field name="model">hotel.reservation</field>
        <field name="inherit_id" ref="hotel.view_hotel_reservation_form" />
        <field name="arch" type="xml">
            <xpath expr="//field[@name='channel_type']" position="after">
                <field name="wchannel_id" attrs='{"readonly": [("able_to_modify_wubook","=",False)], "invisible":[("channel_type","!=", "web")]}' string="OTA"/>
            </xpath>
            <xpath expr="//field[@name='cardex_pending']" position="before">
                <group colspan="6" col="6">
                    <field name="wis_from_channel" readonly="True" invisible="True"/>
                </group>
            </xpath>

            <xpath expr="//field[@name='partner_internal_comment']" position="after">
                <field name="able_to_modify_wubook" invisible="True"/>
                <field name="wcustomer_notes" readonly="1"
                    attrs="{'invisible': [('wrid','=',False)]}"
                    nolabel="1" colspan="2"
                />
            </xpath>

            <xpath expr="//page[@name='days']" position="after">
                <page name="wubook" string="Wubook">
                    <group colspan="4" col="4">
                        <field name="wrid" attrs='{"readonly": [("able_to_modify_wubook","=",False)]}'/>
                        <field name="wchannel_reservation_code" attrs='{"readonly": [("able_to_modify_wubook","=",False)]}'/>
                        <field name="wstatus" attrs='{"readonly": [("able_to_modify_wubook","=",False)]}'/>
                        <field name="wstatus_reason" attrs='{"readonly": [("able_to_modify_wubook","=",False)]}'/>
                        <field name="to_read" invisible="0"/>
                        <field name="to_assign" invisible="0" />
                    </group>
                </page>
            </xpath>

            <!-- ALLOW ONLY-READ -->
            <xpath expr="//field[@name='adults']" position="attributes">
                <attribute name="attrs">{'readonly': [('wis_from_channel','=',True),('able_to_modify_wubook','=',False)]}</attribute>
            </xpath>
            <xpath expr="//field[@name='virtual_room_id']" position="attributes">
                <attribute name="attrs">{'readonly': [('wrid','!=',False),('able_to_modify_wubook','=',False)]}</attribute>
            </xpath>
            <xpath expr="//field[@name='children']" position="attributes">
                <attribute name="attrs">{'readonly': [('wis_from_channel','=',True),('able_to_modify_wubook','=',False)]}</attribute>
            </xpath>
            <xpath expr="//field[@name='checkin']" position="attributes">
                <attribute name="attrs">{'readonly': [('wis_from_channel','=',True),('able_to_modify_wubook','=',False)]}</attribute>
            </xpath>
            <xpath expr="//field[@name='checkout']" position="attributes">
                <attribute name="attrs">{'readonly': [('wis_from_channel','=',True),('able_to_modify_wubook','=',False)]}</attribute>
            </xpath>
            <xpath expr="//field[@name='reservation_line_ids']" position="attributes">
                <attribute name="attrs">{'readonly': [('wis_from_channel','=',True),('able_to_modify_wubook','=',False)]}</attribute>
            </xpath>
        </field>
    </record>


    <!-- Tree view of hotel reservation -->
    <record model="ir.ui.view" id="view_hotel_reservation_tree">
        <field name="model">hotel.reservation</field>
        <field name="inherit_id" ref="hotel.view_hotel_reservation_tree" />
        <field name="arch" type="xml">
            <xpath expr="//field[@name='checkout']" position="after">
                <field name="origin_sale"/>
            </xpath>
        </field>
    </record>

    <!-- Search view of hotel reservation -->
    <record model="ir.ui.view" id="view_hotel_reservation_search">
        <field name="model">hotel.reservation</field>
        <field name="inherit_id" ref="hotel.view_hotel_reservation_search" />
        <field name="arch" type="xml">
            <xpath expr="//field[@name='folio_id']" position="after">
                <field name="wchannel_reservation_code"/>
            </xpath>
            <xpath expr="//group" position="inside">
                <filter name="origin" string="Origin" domain="[]"
                        context="{'group_by':'origin_sale'}"/>
            </xpath>
        </field>
    </record>

     <!--graph view of hotel reservation -->
    <record id="view_hotel_reservation_graph" model="ir.ui.view">
        <field name="name">view.hotel.reservation.graph</field>
        <field name="model">hotel.reservation</field>
        <field name="arch" type="xml">
            <graph type="bar">
                <field name="origin_sale" string="Origin"/>
                <field name="price_total" type="measure" />
            </graph>
        </field>
    </record>

    <!--pivot view of hotel reservation -->
    <record id="view_hotel_pivot_graph" model="ir.ui.view">
        <field name="name">view.hotel.pivot.graph</field>
        <field name="model">hotel.reservation</field>
        <field name="arch" type="xml">
            <pivot string="Reservations">
                <field name="checkin" type="row" />
                <field name="origin_sale" string="Origin" type="col" />
                <field name="price_total" string="Price" type="measure" />
            </pivot>
        </field>
    </record>

</odoo>
