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

    <record id="view_hr_expense_report_tree" model="ir.ui.view">
        <field name="name">hr.expense.report.tree</field>
        <field name="model">hr.expense.report</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree colors="blue:state in ('draft');black:state in ('confirm','accepted','invoiced','paid');gray:state in('cancelled')" string="Expenses Analysis">
                <field name="date" invisible="1"/>
                <field name="employee_id" invisible="1"/>
                <field name="user_id" invisible="1"/>
                <field name="year" invisible="1"/>
                <field name="month" invisible="1"/>
                <field name="day" invisible="1"/>
                <field name="invoice_id" invisible="1"/>
                <field name="analytic_account" invisible="1" groups="analytic.group_analytic_accounting"/>
                <field name="department_id" invisible="1"/>
                <field name="company_id" invisible="1"/>
                <field name="currency_id" invisible="1"/>
                <field name="product_id" invisible="1"/>
                <field name="product_qty" invisible="1"/>
                <field name="state" invisible="1"/>
                <field name="nbr" sum="# of Lines"/>
                <field name="no_of_products" sum="# of Products"/>
                <field name="invoiced" sum="Total Invoiced Lines"/>
                <field name="price_average" avg="Average Price"/>
                <field name="price_total" sum="Total Price"/>
                <field name="delay_confirm"/>
                <field name="delay_valid"/>
            </tree>
        </field>
    </record>

    <record id="view_hr_expense_report_graph" model="ir.ui.view">
         <field name="name">hr.expense.report.graph</field>
         <field name="model">hr.expense.report</field>
         <field name="type">graph</field>
         <field name="arch" type="xml">
             <graph string="Expenses Analysis" type="bar">
                 <field name="employee_id"/>
                 <field name="state" group="True"/>
                 <field name="nbr" operator="+"/>
             </graph>
         </field>
    </record>

    <record id="view_hr_expense_report_search" model="ir.ui.view">
        <field name="name">hr.expense.report.search</field>
        <field name="model">hr.expense.report</field>
        <field name="type">search</field>
        <field name="arch" type="xml">
            <search string="Expenses Analysis">
              <group>
                <filter icon="terp-go-year" string="  Year  "
                      domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;=',time.strftime('%%Y-01-01'))]"
                      help="Expenses during current year"/>
                  <filter icon="terp-go-month" string="   Month   "
                      name="month"
                      domain="[('date','&lt;=',(datetime.date.today()+relativedelta(day=31)).strftime('%%Y-%%m-%%d')),('date','&gt;=',(datetime.date.today()-relativedelta(day=1)).strftime('%%Y-%%m-%%d'))]"
                      help="Expenses during current month"/>
                <filter icon="terp-go-month" string="    Month-1    " separator="1"
                      domain="[('date','&lt;=', (datetime.date.today() - relativedelta(day=31, months=1)).strftime('%%Y-%%m-%%d')),('date','&gt;=',(datetime.date.today() - relativedelta(day=1,months=1)).strftime('%%Y-%%m-%%d'))]"
                      help="Expenses during last month"/>
                  <separator orientation="vertical"/>
                    <filter string="Waiting" icon="terp-gtk-media-pause" domain="[('state', '=' ,'confirm')]"
                    help = "Confirm Expenses"/>
                    <filter string="Approved" icon="terp-check" domain="[('state','=','accepted')]"
                      help = "Approved Expenses"/>
                    <separator orientation="vertical"/>
                    <filter string="Invoiced" icon="terp-dolar" domain="[('state','in', ('invoiced', 'paid'))]"
                      help = "Invoiced Expenses"/>
                    <separator orientation="vertical"/>
                    <field name="employee_id"/>
                    <field name="department_id"/>
            </group>
            <newline/>
            <group expand="0" string="Extended Filters..." groups="base.group_extended">
                <field name="product_id"/>
                <separator orientation="vertical"/>
                <field name="user_id"/>
                <separator orientation="vertical"/>
                <field name="company_id" groups="base.group_multi_company" widget="selection"/>
                <newline/>
                <field name="date" string="Creation Date"/>
                <field name="date_confirm"/>
                <field name="date_valid"/>
            </group>
            <newline/>
            <group expand="1" string="Group By...">
                <filter string="Employee" name="employee" icon="terp-personal" context="{'group_by':'employee_id'}"/>
                <filter string="Validation User" name="User" icon="terp-personal" context="{'group_by':'user_id'}"/>
                <filter string="Department" icon="terp-personal+" context="{'group_by':'department_id'}"/>
                <separator orientation="vertical"/>
                <filter string="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id'}"/>
                <separator orientation="vertical" groups="analytic.group_analytic_accounting"/>
                <filter string="Analytic account" icon="terp-folder-green" context="{'group_by':'analytic_account'}" groups="analytic.group_analytic_accounting"/>
                <separator orientation="vertical" groups="analytic.group_analytic_accounting"/>
                <filter string="State" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
                <filter string="Company" icon="terp-go-home" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
                <separator orientation="vertical"/>
                <filter string="Day" icon="terp-go-today" context="{'group_by':'day'}" help="Creation Date"/>
                <filter string="Month" icon="terp-go-month" context="{'group_by':'month'}" help="Creation Date"/>
                <filter string="Year" icon="terp-go-year" context="{'group_by':'year'}" help="Creation Date"/>
            </group>
            </search>
        </field>
    </record>

    <record id="action_hr_expense_report_all" model="ir.actions.act_window">
        <field name="name">Expenses Analysis</field>
        <field name="res_model">hr.expense.report</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,graph</field>
        <field name="context">{'search_default_month':1,'search_default_employee':1,'group_by_no_leaf':1,'group_by':[]}</field>
        <field name="search_view_id" ref="view_hr_expense_report_search"/>
    </record>

    <menuitem id="hr.menu_hr_reporting" name="Reporting" parent="hr.menu_hr_root" sequence="10"/>
    <menuitem action="action_hr_expense_report_all" id="menu_hr_expense_report_all" parent="hr.menu_hr_reporting" sequence="2"/>

</data>
</openerp>
