<odoo>
    <!-- Form view of hotel folio -->
    <record id="view_hotel_folio_form" model="ir.ui.view">
        <field name="name">hotel.folio.form</field>
        <field name="model">hotel.folio</field>
        <field name="arch" type="xml">
            <form>
                <header>
                    <button
                        name="action_confirm"
                        invisible="state != 'draft'"
                        string="Confirm Sale"
                        class="btn-primary"
                        type="object"
                    />
                    <button
                        name="%(sale.action_view_sale_advance_payment_inv)d"
                        string="Create Invoice"
                        type="action"
                        class="btn-primary"
                        invisible="state in ['draft','cancel','done'] or ['invoice_status', 'in', 'invoiced']"
                    />
                    <button
                        name="action_cancel_draft"
                        invisible="state != 'cancel'"
                        string="Set to Draft"
                        type="object"
                        class="oe_highlight"
                    />
                    <button
                        name="action_cancel"
                        string="Cancel"
                        invisible="state != 'sale'"
                        type="object"
                        class="oe_highlight"
                    />
                    <button
                        name="action_cancel"
                        string="Cancel"
                        invisible="state != 'draft'"
                        type="object"
                        class="oe_highlight"
                    />
                    <field
                        name="state"
                        select="2"
                        widget="statusbar"
                        statusbar_visible="draft,sent,sale,done"
                    />
                </header>
                <sheet>
                    <label for="name" string="Folio Number" />
                    <h1>
                        <field name="name" colspan="4" readonly="1" />
                    </h1>
                    <group colspan="4" col="4">
                        <field name="date_order" readonly="1" />
                        <field name="warehouse_id" string="Branch" />
                        <field name="invoice_status" />
                        <field
                            name="hotel_invoice_id"
                            invisible="state not in ['sale','done','cancel']"
                            readonly="1"
                        />
                    </group>
                    <notebook>
                        <page name="folio" string="Folio">
                            <group colspan="4" col="4">
                                <field
                                    name="partner_id"
                                    string="Guest Name"
                                    required="1"
                                />
                                <field
                                    name="partner_invoice_id"
                                    domain="[('parent_id','=',partner_id)]"
                                />
                                <field name="pricelist_id" />
                                <field
                                    name="partner_shipping_id"
                                    domain="[('parent_id','=',partner_id)]"
                                />
                                <field name="company_id" invisible="1" />
                            </group>
                            <newline />
                            <group colspan="4" col="4" invisible="1">
                                <field
                                    name="checkin_date"
                                    readonly="state != 'draft'"
                                />
                                <field
                                    name="checkout_date"
                                    readonly="state != 'draft'"
                                />
                                <field name="duration" readonly="1" />
                                <field name="duration_dummy" invisible="1" />
                            </group>
                            <separator string="Room Lines" colspan="4" />
                            <field
                                name="room_line_ids"
                                colspan="4"
                                readonly="state not in ['draft','sent']"
                                string="Room Line"
                                nolabel="1"
                                context="{'default_checkin_date':checkin_date,
                                        'default_checkout_date':checkout_date}"
                            >
                                <tree editable="bottom">
                                    <field
                                        name="company_id"
                                        options="{'no_create': True}"
                                        groups="base.group_multi_company"
                                        column_invisible="1"
                                    />
                                    <field name="checkin_date" />
                                    <field name="checkout_date" />
                                    <field
                                        name="product_id"
                                        string="Room No"
                                        required="1"
                                        context="{'partner_id':parent.partner_id,'quantity':product_uom_qty,'pricelist':parent.pricelist_id,'uom':product_uom, 'checkin_date':checkin_date, 'checkout_date':checkout_date}"
                                        domain="[('isroom','=',True)]"
                                        options="{'no_open': True}"
                                        groups="uom.group_uom"
                                    />
                                    <field name="name" />
                                    <field
                                        name="product_uom"
                                        string="Rent(UOM)"
                                        readonly="state in ['sale','done', 'cancel']"
                                        context="{'company_id': parent.company_id}"
                                        options="{'no_open': True}"
                                        groups="uom.group_uom"
                                    />
                                    <field name="product_uom_qty" string="Duration" />
                                    <field
                                        name="product_uom_category_id"
                                        column_invisible="1"
                                    />
                                    <field name="price_unit" />
                                    <field
                                        domain="[('type_tax_use','=','sale'),('company_id','=',parent.company_id)]"
                                        name="tax_id"
                                        options="{'no_create': True}"
                                        widget="many2many_tags"
                                    />
                                    <field
                                        groups="product.group_discount_per_so_line"
                                        name="discount"
                                    />
                                        <!-- TODO: Need to check groups="account.group_show_line_subtotals_tax_excluded" -->
                                    <field name="price_subtotal" widget="monetary" />
                                        <!-- TODO: Need to check groups="account.group_show_line_subtotals_tax_included" -->
                                    <field name="price_total" widget="monetary" />
                                    <field name="currency_id" column_invisible="1" />
                                    <field name="state" column_invisible="1" />
                                </tree>
                            </field>
                            <separator string="Service Lines" colspan="4" />
                            <field
                                name="service_line_ids"
                                colspan="4"
                                readonly="state not in ['draft','sent']"
                                string="Service Line"
                                nolabel="1"
                                context="{'deafult_ser_checkin_date':checkin_date,
                                'deafult_ser_checkout_date':checkout_date
                                }"
                            >

                                <tree editable="bottom">
                                    <field
                                        name="product_id"
                                        required="1"
                                        domain="[('isservice','=',True)]"
                                        context="{'partner_id':parent.partner_id,'quantity':product_uom_qty,'pricelist':parent.pricelist_id,'hotel':parent.warehouse_id,'uom':product_uom}"
                                        options="{'no_open': True}"
                                        groups="uom.group_uom"
                                    />
                                    <field
                                        name="ser_checkout_date"
                                        column_invisible="1"
                                    />
                                    <field
                                        name="ser_checkin_date"
                                        column_invisible="1"
                                    />
                                    <field name="name" />
                                    <field
                                        name="company_id"
                                        options="{'no_create': True}"
                                        groups="base.group_multi_company"
                                        column_invisible="1"
                                    />
                                    <field name="product_uom_qty" string="Duration" />
                                    <field
                                        name="product_uom_category_id"
                                        column_invisible="1"
                                    />
                                    <field
                                        name="product_uom"
                                        string="Rent(UOM)"
                                        readonly="state in ['sale','done', 'cancel']"
                                        context="{'company_id': parent.company_id}"
                                        options="{'no_open': True}"
                                        groups="uom.group_uom"
                                    />
                                    <field name="price_unit" />
                                    <field
                                        domain="[('type_tax_use','=','sale'),('company_id','=',parent.company_id)]"
                                        name="tax_id"
                                        options="{'no_create': True}"
                                        widget="many2many_tags"
                                    />
                                    <field
                                        groups="product.group_discount_per_so_line"
                                        name="discount"
                                    />
                                         <!-- TODO: Need to check groups="account.group_show_line_subtotals_tax_excluded" -->
                                    <field name="price_subtotal" widget="monetary" />
                                        <!-- TODO: Need to check groups="account.group_show_line_subtotals_tax_included" -->
                                    <field name="price_total" widget="monetary" />
                                    <field column_invisible="1" name="currency_id" />
                                    <field name="state" column_invisible="1" />
                                </tree>
                            </field>
                            <group colspan="2" class="oe_subtotal_footer oe_right">
                                <field
                                    name="amount_untaxed"
                                    sum="Untaxed amount"
                                    widget='monetary'
                                />
                                <field name="amount_tax" widget='monetary' />
                                <div class="oe_subtotal_footer_separator oe_inline">
                                    <label for="amount_total" />
                                </div>
                                <field
                                    name="amount_total"
                                    nolabel="1"
                                    sum="Total amount"
                                    widget='monetary'
                                />
                            </group>
                            <div class="oe_clear" />
                        </page>
                        <page name='other_data' string="Other data">
                            <group>
                                <field name="user_id" />
                                <field
                                    name="hotel_policy"
                                    readonly="state not in ['draft']"
                                />
                                <field name="client_order_ref" />
                            </group>
                        </page>
                        <page name="invoice_history" string="History">
                            <separator string="Related invoices" colspan="4" />
                            <field name="invoice_ids" colspan="4" nolabel="1" />
                        </page>
                    </notebook>
                </sheet>
            </form>
        </field>
    </record>
    <!-- Tree view of hotel folio -->
    <record id="view_hotel_folio_tree" model="ir.ui.view">
        <field name="name">hotel.folio.tree</field>
        <field name="model">hotel.folio</field>
        <field name="arch" type="xml">
            <tree>
                <field name="checkin_date" />
                <field name="checkout_date" />
                <field name="name" />
                <field name="partner_id" />
                <field name="date_order" />
                <field name="state" />
                <field name="amount_total" sum="Total amount" />
            </tree>
        </field>
    </record>
    <!-- Calendar view of hotel folio -->
    <record id="hotel_folio_calendar_view" model="ir.ui.view">
        <field name="name">Hotel- Folios Calendar</field>
        <field name="model">hotel.folio</field>
        <field name="arch" type="xml">
            <calendar
                string="Folios"
                date_start="checkin_date"
                color="user_id"
                date_stop="checkout_date"
            >
                <field name="name" />
                <field name="partner_id" />
                <field name="duration" />
            </calendar>
        </field>
    </record>
    <!-- Search view of hotel folio -->
    <record id="view_hotel_folio_search" model="ir.ui.view">
        <field name="name">hotel.folio.search</field>
        <field name="model">hotel.folio</field>
        <field name="arch" type="xml">
            <search string="Tables Detail">
                <field name="partner_id" />
                <field name="name" filter_domain="[('name', 'ilike', self)]" />
                <filter
                    name="checkout_date"
                    string="Current Booking"
                    domain="[('checkout_date','&gt;=',datetime.datetime.now().replace(hour=0, minute=0, second=0)),('checkin_date','&lt;=',datetime.datetime.now().replace(hour=23, minute=59, second=59))]"
                />
                <group expand="0" string="Group By">
                    <filter
                        name="date_order"
                        string="Order By Month"
                        context="{'group_by':'date_order'}"
                    />
                    <filter
                        name="partner_id"
                        string="Customer"
                        context="{'group_by':'partner_id'}"
                    />
                </group>
            </search>
        </field>
    </record>
    <!--graph view of hotel folio -->
    <record id="view_hotel_folio_graph" model="ir.ui.view">
        <field name="name">view.hotel.folio.graph</field>
        <field name="model">hotel.folio</field>
        <field name="arch" type="xml">
            <graph type="bar">
                <field name="date_order" type="row" />
                <field name="amount_total" type="measure" />
            </graph>
        </field>
    </record>
</odoo>
