<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <!--=== Hotel Service Line ==== -->

    <!-- Form view of Service Line -->
    <record model="ir.ui.view" id="hotel_service_line_view_form">
        <field name="name">hotel.service.line.form</field>
        <field name="model">hotel.service.line</field>
        <field name="arch" type="xml">
            <form string="Service Line">
                <group>
                    <field name="product_id" />
                    <field name="day_qty"/>
                    <field name="date" />
                    <field name="price_unit" />
                    <field name="hotel_id" invisible="1"/>
                </group>
            </form>
        </field>
    </record>

    <!-- Tree views of hotel service Line -->
    <record model="ir.ui.view" id="hotel_service_line_view_tree">
        <field name="name">hotel.service.line.tree</field>
        <field name="model">hotel.service.line</field>
        <field name="arch" type="xml">
            <tree string="Hotel By Day">
                <field name="product_id" />
                <field name="day_qty"/>
                <field name="date" />
                <field name="hotel_id" invisible="1"/>
            </tree>
        </field>
    </record>

    <record model="ir.ui.view" id="hotel_service_line_report_view_tree">
        <field name="name">hotel.service.line.report.tree</field>
        <field name="model">hotel.service.line</field>
        <field name="arch" type="xml">
            <tree string="Service By Day">
                <field name="product_id" />
                <field name="date" />
                <field name="day_qty"/>
                <field name="price_unit" />
                <field name="service_id" />
                <field name="room_id" />
                <field name="tax_ids" invisible="1"/>
                <field name="discount" />
                <field name="price_total" />
            </tree>
        </field>
    </record>

    <!-- Search Views -->

    <record model="ir.ui.view" id="hotel_service_line_view_search">
        <field name="name">hotel.service.line.search</field>
        <field name="model">hotel.service.line</field>
        <field name="arch" type="xml">
            <search string="Services By Day">
                <field name="service_id" />
                <filter string="Today"
                            domain="[('date', '=', context_today().strftime('%Y-%m-%d'))]"
                            help="Current Booking" />
                <filter string="Tomorrow"
                            domain="[('date', '=', (context_today()+datetime.timedelta(days=1)).strftime('%Y-%m-%d'))]"
                             />
                <filter string="Next 7 days"
                            domain="[('date', '&gt;', context_today().strftime('%Y-%m-%d')),
                                ('date', '&lt;', (context_today()+datetime.timedelta(days=7)).strftime('%Y-%m-%d'))]"
                             />
                <group expand="0" string="Group By">
                    <filter string="By Month" name="date_by_month"
                                context="{'group_by':'date', 'default_order': 'date asc'}"/>
                    <filter string="By Week" name="date_by_week"
                            context="{'group_by':'date:week', 'default_order': 'date'}"/>
                    <filter string="By Day" name="date_by_week"
                            context="{'group_by':'date:day', 'default_order': 'date'}"/>
                    <filter string="Product" name="product_id"
                            context="{'group_by':'product_id', 'default_order': 'product_id'}"/>
                </group>
            </search>
        </field>
    </record>

    <!-- Action for hotel service line from Form Folio/Reservation-->
    <record model="ir.actions.act_window" id="action_hotel_service_line_form">
        <field name="name">Hotel Services</field>
        <field name="res_model">hotel.service.line</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>

<!--
    <menuitem name="Services as Products" id="menu_open_hotel_service_line_form"
        action="action_hotel_service_line_form" sequence="8"
        parent="hotel.menu_hotel_service" />
-->

    <act_window
        id="action_service_line"
        name="Services By Day"
        res_model="hotel.service.line"
        view_mode="tree,form"
        view_id = "hotel.hotel_service_line_report_view_tree" />

    <menuitem
        id="menu_hotel_service_line"
        name="Services by Day"
        parent="hotel.hotel_reports_menu"
        sequence="30"
        action="action_service_line" />

</odoo>
