<?xml version="1.0"?>
<openerp>
    <data>
          <menuitem icon="STOCK_PREFERENCES" id="base.menu_tools" name="Tools" sequence="28"/>
          <menuitem name="Lunch Order" parent="base.menu_tools"
              id="menu_lunch" sequence="1" />

          <menuitem name="Reporting" parent="base.menu_tools"
              id="base.menu_lunch_reporting" sequence="6" groups="base.group_system,base.group_tool_manager"/>

          <menuitem name="Lunch Orders"
              parent="base.menu_lunch_reporting"
              id="menu_lunch_reporting_order" sequence="1" />

          <menuitem name="Configuration" parent="base.menu_tools"
              id="base.menu_lunch_survey_root" sequence="20" groups="base.group_system"/>

          <menuitem name="Lunch" parent="base.menu_lunch_survey_root"
              id="menu_lunch_category_root_configuration" sequence="1" />

<!-- Lunch order Form view -->

          <record model="ir.ui.view" id="view_lunch_order_form">
            <field name="name">Order</field>
            <field name="model">lunch.order</field>
            <field name="arch" type="xml">
                <form string="Order">
                    <group colspan="2" col="4">
                        <field name="user_id" select="1"/>
                        <field name="date" select="1"/>
                        <field name="product" select="1" on_change="onchange_product(product)"/>
                        <field name="category"/>
                        <field name="descript"/>
                        <field name="price"/>
                        <field name="cashmove"/>
                        <field name="state"/>
                    </group>
                </form>
            </field>
        </record>

<!-- Lunch order Tree view -->

        <record model="ir.ui.view" id="view_lunch_order_tree">
            <field name="name">Order</field>
            <field name="model">lunch.order</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree colors="blue:state in ('draft');black:state in ('confirmed')" string="Order">
                    <field name="date"/>
                    <field name="user_id"/>
                    <field name="product"/>
                    <field name="descript"/>
                    <field name="category"/>
                    <field name="price" sum="Total price"/>
                    <field name="state"/>
                    <button colspan="1"
                              name="%(action_lunch_order_confirm)d"
                              string="Confirm Order"
                              type="action" states="draft"
                              icon="terp-gtk-go-back-rtl" />
                    <button colspan="1"
                              name="%(action_lunch_order_cancel)d"
                              string="Cancel Order"
                              type="action" states="confirmed"
                              icon="gtk-cancel" />
                </tree>
            </field>
        </record>

<!-- Lunch order Search view -->

        <record id="view_lunch_order_filter" model="ir.ui.view">
            <field name="name">lunch.order.list.select</field>
            <field name="model">lunch.order</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search Lunch Order">
                    <filter icon="terp-check" string="To Confirm" domain="[('state','=','draft')]"/>
                    <filter icon="terp-camera_test" string="Confirmed" domain="[('state','=',('confirmed'))]"/>
                    <separator orientation="vertical"/>
                    <filter icon="terp-go-today" name="Today" string="Today" domain="[('date','=',time.strftime('%%Y-%%m-%%d'))]"/>
                    <separator orientation="vertical"/>
                    <field name="user_id"/>
                    <field name="date"/>
                    <newline/>
                    <group expand="0" string="Group By..." colspan="4" col="20">
                        <filter string="Category" icon="terp-stock_symbol-selection" domain="[]"  context="{'group_by':'category'}"/>
                    </group>
                </search>
            </field>
        </record>

<!-- Lunch order Action -->

        <record model="ir.actions.act_window" id="action_lunch_order_form">
                <field name="name">Lunch Orders</field>
                <field name="res_model">lunch.order</field>
                <field name="view_mode">tree,form</field>
                <field name="search_view_id" ref="view_lunch_order_filter"/>
                <field name="context">{"search_default_Today":1}</field>
        </record>

        <menuitem name="Lunch Orders" parent="menu_lunch"
            id="menu_lunch_order_form" action="action_lunch_order_form" />

<!--  Cash Box Form view  -->

        <record model="ir.ui.view" id="view_lunch_cashbox_form">
            <field name="name">Cashboxes</field>
            <field name="model">lunch.cashbox</field>
            <field name="arch" type="xml">
                <form string="Cashboxes">
                    <field name="name" select="1"/>
                    <field name="manager" select="1"/>
                </form>
            </field>
        </record>

<!--  Cash Box Tree view  -->

        <record model="ir.ui.view" id="view_lunch_cashbox_tree">
            <field name="name">Cashboxes</field>
            <field name="model">lunch.cashbox</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Cashboxes" colors="red:sum_remain&lt;=0">
                    <field name="name" select="1"/>
                    <field name="manager" select="1"/>
                    <field name="sum_remain" select="1"/>
                </tree>
            </field>
        </record>

<!--  Cash Box Action  -->

        <record model="ir.actions.act_window" id="action_lunch_cashbox_form">
                <field name="name"> Cashboxes </field>
                <field name="res_model">lunch.cashbox</field>
        </record>

        <menuitem name="Cashboxes"
            parent="menu_lunch_category_root_configuration"
            id="menu_lunch_cashbox_form"
            action="action_lunch_cashbox_form" />

<!-- Cash Move Form view  -->

        <record model="ir.ui.view" id="view_lunch_cashmove_form">
            <field name="name">CashMove</field>
            <field name="model">lunch.cashmove</field>
            <field name="arch" type="xml">
                <form string="CashMove">
                    <field name="name" select="1"/>
                    <field name="user_cashmove" select="1"/>
                    <field name="amount"/>
                    <field name="box" select="1"/>
                    <field name="create_date" select="1"/>
                    <field name="active" select="1"/>
                </form>
            </field>
        </record>

<!-- Cash Move Tree view  -->

        <record model="ir.ui.view" id="view_lunch_cashmove_tree">
            <field name="name">CashMove</field>
            <field name="model">lunch.cashmove</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="CashMove" editable="top">
                    <field name="create_date"/>
                    <field name="box" select="1"/>
                    <field name="name" select="1" required="1"/>
                    <field name="user_cashmove" select="1"/>
                    <field name="amount" select="1" sum="Total amount"/>
                </tree>
            </field>
        </record>

<!--  Cash Move Search View  -->

        <record id="view_lunch_cashmove_filter" model="ir.ui.view">
            <field name="name">lunch.cashmove.list.select</field>
            <field name="model">lunch.cashmove</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search CashMove">
                    <filter icon="terp-go-today" name="Today" string="Today" domain="[('create_date','&lt;=',time.strftime('%%Y-%%m-%%d 23:59:59'))]"/>
                    <separator orientation="vertical"/>
                    <field name="name"/>
                    <field name="user_cashmove"/>
                    <field name="create_date"/>
                    <newline/>
                    <group expand="0" string="Group By..." colspan="4" col="20">
                        <filter string="User" icon="terp-personal" domain="[]"  context="{'group_by':'user_cashmove'}"/>
                        <separator orientation="vertical"/>
                        <filter string="Box" icon="terp-dolar" domain="[]"  context="{'group_by':'box'}"/>
                        <separator orientation="vertical"/>
                        <filter string="Date" icon="terp-go-today" domain="[]"  context="{'group_by':'create_date'}"/>
                    </group>
                </search>

            </field>
        </record>

<!-- Cash Move Action  -->

        <record model="ir.actions.act_window" id="action_lunch_cashmove_form">
                <field name="name">Cash Moves</field>
                <field name="res_model">lunch.cashmove</field>
                <field name="search_view_id" ref="view_lunch_cashmove_filter"/>
                <field name="context">{"search_default_Today":1}</field>
        </record>

        <menuitem name="Cash Moves" parent="menu_lunch"
            id="menu_lunch_cashmove_form"
            action="action_lunch_cashmove_form" />

<!-- Lunch Category Form view  -->

        <record model="ir.ui.view" id="view_lunch_category_form">
            <field name="name"> Category of product </field>
            <field name="model">lunch.category</field>
            <field name="arch" type="xml">
                <form string="Category">
                    <separator string="Category related to Products" colspan="4"/>
                    <field name="name" select="1"/>
                </form>
            </field>
        </record>

<!-- Lunch Category Tree view  -->

        <record model="ir.ui.view" id="view_lunch_category_tree">
            <field name="name">Category</field>
            <field name="model">lunch.category</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Order">
                    <field name="name" select="1"/>
                </tree>
            </field>
        </record>

<!-- Lunch Category Action  -->

        <record model="ir.actions.act_window" id="action_lunch_category_form">
            <field name="name"> Product Categories </field>
            <field name="res_model">lunch.category</field>
        </record>

<!-- Lunch Product Form view  -->

        <record model="ir.ui.view" id="view_lunch_product_form">
            <field name="name">Products</field>
            <field name="type">form</field>
            <field name="model">lunch.product</field>
            <field name="arch" type="xml">
                <form string="Products">
                    <field name="name" select="1"/>
                    <field name="category_id" widget="selection"/>
                    <field name="description" />
                    <field name="price" />
                    <field name="active"/>
                </form>
            </field>
        </record>

<!-- Lunch Product Tree view  -->

        <record model="ir.ui.view" id="view_lunch_product_tree">
            <field name="name">Products</field>
            <field name="model">lunch.product</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Products">
                    <field name="name"/>
                    <field name="category_id"/>
                    <field name="description"/>
                    <field name="price"/>
                </tree>
            </field>
        </record>

<!-- Lunch Product Search view  -->

        <record model="ir.ui.view" id="view_lunch_product_search">
            <field name="name">Products</field>
            <field name="model">lunch.product</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Products">
                    <field name="name" />
                    <field name="category_id" widget="selection"/>
                    <field name="description" />
                    <field name="price"/>
                </search>
            </field>
        </record>

<!-- Lunch Product Action  -->

        <record model="ir.actions.act_window" id="action_lunch_product_form">
            <field name="name">Products</field>
            <field name="res_model">lunch.product</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="view_id" ref="view_lunch_product_tree"/>
            <field name="search_view_id" ref="view_lunch_product_search"/>
        </record>

        <menuitem name="Products"
            parent="menu_lunch_category_root_configuration"
            id="menu_lunch_product_form" action="action_lunch_product_form"
            sequence="2" />

        <menuitem name="Product Categories"
            parent="menu_lunch_category_root_configuration"
            id="menu_lunch_category_form"
            action="action_lunch_category_form" sequence="1" />


<!-- Lunch Amount Tree view -->

        <record model="ir.ui.view" id="view_report_lunch_amount_tree">
            <field name="name">Lunch amount</field>
            <field name="model">report.lunch.amount</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Box Amount by User">
                     <field name="date" invisible="1"/>
                    <field name="year" invisible="1"/>
                    <field name="day" invisible="1"/>
                    <field name="month" invisible="1"/>
                    <field name="box" select="1"/>
                    <field name="user_id" select="1"/>
                    <field name="amount" select="1" sum="Total box" />
                </tree>
            </field>
        </record>

<!-- Lunch Amount Form view -->

        <record model="ir.ui.view" id="view_report_lunch_amount_form">
            <field name="name">Lunch amount</field>
            <field name="model">report.lunch.amount</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Box Amount by User">
                    <field name="user_id" select="1"/>
                    <field name="box" select="1"/>
                    <field name="amount" select="1"/>
                </form>
            </field>
        </record>

<!-- Lunch Amount Search view -->

        <record model="ir.ui.view" id="view_report_lunch_amount_search">
            <field name="name">Lunch amount</field>
            <field name="model">report.lunch.amount</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Box Amount by User">
                    <group>
                        <filter icon="terp-go-year" string="  Year  "
                        domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;=',time.strftime('%%Y-01-01'))]"
                        help="Box amount in current year"/>
                        <filter icon="terp-go-month" string="   Month   "
                        name="month"
                        domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;=',time.strftime('%%Y-%%m-01'))]"
                        help="Box amount in current month"/>
                        <filter icon="terp-go-month"
                         string="    Month-1    "
                         separator="1"
                         domain="[('date','&lt;=', (datetime.date (int(time.strftime('%%Y')), datetime.date.today().month, 1) - datetime.timedelta (days = 1)).strftime('%%Y-%%m-%%d')),('date','&gt;',(datetime.date (int(time.strftime('%%Y')), datetime.date.today().month-1, 1)).strftime('%%Y-%%m-%%d'))]"
                         help="Box amount in last month"/>
                    <separator orientation="vertical"/>
                        <field name="user_id" select="1"/>
                        <field name="box" select="1"/>
                        <field name="amount" select="1"/>
                    </group>
                    <newline/>
                    <group expand="0" string="Group By..." colspan="4" col="4">
                        <filter string="Box" icon="terp-dolar" context="{'group_by':'box'}"/>
                    </group>
                </search>
            </field>
        </record>

<!-- Lunch Amount Action -->

        <record model="ir.actions.act_window" id="action_report_lunch_amount_tree">
            <field name="name">Cash Position by User</field>
            <field name="res_model">report.lunch.amount</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="search_view_id" ref="view_report_lunch_amount_search"/>
        </record>

        <menuitem name="Cash Position by User"
            parent="menu_lunch_reporting_order"
            action="action_report_lunch_amount_tree"
            id="menu_lunch_report_amount_tree" />

    </data>
</openerp>


