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

        <!--
        Analytic Account form 

        Remove information on Account data => because they move on analysis sheet
        create a page with invoicing informations
        -->
        <record id="hr_timesheet.account_analytic_account_form_form" model="ir.ui.view">
            <field name="name">account.analytic.account.invoice.form.inherit</field> 
            <field name="model">account.analytic.account</field> 
            <field name="type">form</field> 
            <field name="inherit_id" ref="account.view_account_analytic_account_form"/>
            <field eval="18" name="priority"/>
            <field name="arch" type="xml">
                <form>
                    <notebook position="inside">
                        <page string="Analysis summary">
                            <separator colspan="4" string="Work done stats"/>

                            <field name="total_cost"/>
                            <field name="remaining_ca"/>
                            <field name="ca_invoiced"/>
                            <field name="ca_theorical"/>
                            <newline/>
                            <!-- <field name="old"/> -->
                            <field name="hours_quantity"/>
                            <field name="hours_qtt_invoiced"/>
                            <field name="remaining_hours"/>
                            <newline/>
                            <separator colspan="4" string="Analysis stats"/>

                            <field name="revenue_per_hour"/>
                            <field name="real_margin"/>
                            <field name="theorical_margin"/>
                            <field name="real_margin_rate"/>
                            <separator colspan="4" string="Key dates"/>

                            <field name="last_invoice_date"/>

                            <field name="last_worked_invoiced_date" select="2"/>
                            <field name="last_worked_date"/>
                            <separator colspan="4" string="To be invoiced"/>
                            <field name="hours_qtt_non_invoiced"/>
                            <field name="ca_to_invoice" select="2"/>

                        </page>
                        <page string="Stats by month">  
                            <field colspan="4" name="month_ids" nolabel="1">
                                <tree string="Month">
                                    <field name="month"/>
                                    <field name="unit_amount" widget="float_time"/>
                                </tree>
                            </field>
                        </page>
                        <page string="Stats by user"> 
                            <field colspan="4" name="user_ids" nolabel="1">
                                <tree string="Users">
                                    <field name="user"/>
                                    <field name="unit_amount" widget="float_time"/>
                                </tree>
                            </field>
                        </page>
                    </notebook>

                </form>
            </field>
        </record>

        <!-- Add information on Account analytic list for the project management -->
        <record id="view_account_analytic_account_tree_c2c_2" model="ir.ui.view">
            <field name="name">account.analytic.account.tree</field>
            <field name="model">account.analytic.account</field>
            <field name="inherit_id" ref="account.view_account_analytic_account_list"/>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <field name="quantity" position="replace">
                    <field name="hours_quantity"/>
                    <field name="hours_qtt_non_invoiced"/>
                    <field name="remaining_hours"/>
                </field>
            </field>
        </record>
        <record id="view_account_analytic_account_tree_c2c_3" model="ir.ui.view"> 
            <field name="name">account.analytic.account.tree</field> 
            <field name="model">account.analytic.account</field> 
            <field name="inherit_id" ref="account.view_account_analytic_account_list"/>

            <field name="type">tree</field> 
            <field name="arch" type="xml"> 
                <field name="date" position="before"> 
                    <field name="last_invoice_date"/>

                    <field name="ca_to_invoice"/>
                </field>

            </field>

        </record>

        <record id="view_account_analytic_simplified" model="ir.ui.view">
            <field name="name">account.analytic.account.simplified.tree</field>
            <field name="model">account.analytic.account</field>
            <field name="type">tree</field>
            <field eval="20" name="priority"/>
            <field name="arch" type="xml">
                <tree string="Analytic accounts">
                    <field name="code"/>
                    <field name="complete_name"/>
                    <field name="hours_qtt_non_invoiced"/>
                    <field name="remaining_hours"/>
                    <field name="ca_to_invoice"/>
                    <field name="last_invoice_date"/>

                </tree>
            </field>
        </record>

    </data>
</terp>