<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="account_analytic_account_form_expense_form" model="ir.ui.view">
            <field name="name">account.analytic.account.form.expense.inherit</field>
            <field name="model">account.analytic.account</field>
            <field eval="60" name="priority"/>
            <field name="inherit_id" ref="account_analytic_analysis.account_analytic_account_form_form"/>
            <field name="arch" type="xml">
                <xpath expr='//tr[@name="total"]' position='before'>
                    <tr>
                        <td class="oe_timesheet_grey">
                            <label for="charge_expenses"/>
                        </td><td class="oe_timesheet_grey">
                            <field name="charge_expenses"/>
                        </td><td>
                            <field class="oe_form_inline" name="est_expenses" attrs="{'invisible': [('charge_expenses','=',False)]}"/>
                        </td><td>
                            <field class="oe_form_inline" name="expense_invoiced" attrs="{'invisible': [('charge_expenses','=',False)]}"/>
                        </td><td>
                            <field class="oe_form_inline" name="remaining_expense" attrs="{'invisible': [('charge_expenses','=',False)]}"/>
                        </td><td>
                            <field class="oe_form_inline" name="expense_to_invoice" attrs="{'invisible': [('charge_expenses','=',False)]}"/>
                        </td><td attrs="{'invisible': [('charge_expenses','=',False)]}" class="oe_timesheet_action">
                            <span attrs="{'invisible': [('expense_to_invoice','=',0)]}" class="oe_grey">
                                <button
                                    name="hr_to_invoice_expense"
                                    class="oe_link"
                                    string="⇒ Invoice" type="object"
                                    />
                                or view
                            </span>
                            <span attrs="{'invisible': [('expense_to_invoice','&lt;&gt;',0)]}" class="oe_grey">
                                Nothing to invoice, create 
                            </span>
                            <button
                                name="open_hr_expense"
                                class="oe_link"
                                string="Expenses" type="object"/>
                        </td>
                    </tr>
                </xpath>
                <xpath expr="//p[@name='invoice_on_timesheets_label']" position="attributes">
                    <attribute name="attrs">{'invisible': [('invoice_on_timesheets','=',False),('charge_expenses','=',False)]}</attribute>
                </xpath>
                <xpath expr="//field[@name='pricelist_id']" position="attributes">
                    <attribute name="attrs">{'required': ['|',('invoice_on_timesheets','=',True),('charge_expenses','=',True)], 'invisible':[('invoice_on_timesheets','=',False), ('charge_expenses','=',False)]}</attribute>
                </xpath>
                <xpath expr="//field[@name='to_invoice']" position="attributes">
                    <attribute name="attrs">{'required': ['|',('invoice_on_timesheets','=',True),('charge_expenses','=',True)]}</attribute>
                    <attribute name="string">Expenses and Timesheet Invoicing Ratio</attribute>
                </xpath>
            </field>
        </record>
        
        <!--<record id="project_form_expense_form" model="ir.ui.view">
            <field name="name">project.project.form.expense.inherit</field>
            <field name="model">project.project</field>
            <field name="inherit_id" ref="analytic_contract_project.project_account_analytic_account_form"/>
            <field eval="20" name="priority"/>
            <field name="arch" type="xml">
                <xpath expr='//div[@name="end_of_tabl_hook"]' position='before'>
                        <tr>
                            <th class="oe_border_right">Charge Expenses</th>
                            <td><field name="charge_expenses" nolabel="1"/></td>
                            <td><field class="oe_th_110px" name="est_expenses" nolabel="1" attrs="{'invisible': [('charge_expenses','=',0)]}"/></td>
                            <td class="oe_th_110px"><field name="expense_invoiced" nolabel="1" attrs="{'invisible': [('charge_expenses','=',0)]}"/></td>
                            <td class="oe_th_110px oe_border_right"><field name="remaining_expense" nolabel="1" attrs="{'invisible': [('charge_expenses','=',0)]}"/></td>
                            <td class="oe_th_110px"><field name="expense_to_invoice" nolabel="1" attrs="{'invisible': [('charge_expenses','=',0)]}"/></td>
                            <td width="10px"></td>
                            <td><button icon="gtk-select-all" class= "oe_btn_width" name="open_hr_expense" string="Expenses" type="object" attrs="{'invisible': [('charge_expenses','=',0)]}"/></td>
                            <td><button icon="terp-dolar" class= "oe_btn_width" name="hr_to_invoiced_expense" string="Invoice Expenses" type="object" attrs="{'invisible': [('charge_expenses','=',0)]}"/></td>
                        </tr>
                </xpath>
            </field>
        </record>-->
    </data>
</openerp>
