<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="account_analytic_account_form_form" model="ir.ui.view">
            <field name="name">account.analytic.account.invoice.form</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 name="arch" type="xml">
                <field name="user_id" position="after">
                    <group colspan="4" col="4">
                        <separator colspan="4" string="Invoicing Data"/>
                        <field name="pricelist_id" domain="[('type','=','sale')]" widget="selection"/>
                        <field name="to_invoice" widget="selection" />
                        <field name="amount_max"/>
                        <field name="amount_invoiced"/>
                        <separator colspan="4"/>
                        <group col="9" colspan="8">
	                        <field name="state" readonly="1"/>
	                        <button name="set_cancel" string="Cancel" type="object" states="open,pending" icon="gtk-cancel"/>
	                        <button name="set_open" string="Reactivate Account" type="object" states="pending,cancelled,close" icon="gtk-ok"/>
	                        <button name="set_pending" string="Pending" type="object" states="open" icon="gtk-media-pause"/>
	                        <button name="set_close" string="Close" type="object" states="open,pending" icon="terp-dialog-close"/>
                        </group>
                    </group>
                </field>
            </field>
        </record>

        <record id="hr_timesheet_line_form" model="ir.ui.view">
            <field name="name">hr.analytic.timesheet.form</field>
            <field name="model">hr.analytic.timesheet</field>
            <field name="type">form</field>
            <field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_form"/>
            <field name="arch" type="xml">
                <xpath expr='//separator[@string="Invoicing"]' position='after'>
                    <field name="to_invoice"/>
                    <field name="invoice_id"/>
                </xpath>
            </field>
        </record>

        <record id="hr_timesheet_line_form2" model="ir.ui.view">
            <field name="name">hr.analytic.timesheet.form2</field>
            <field name="model">hr.analytic.timesheet</field>
            <field name="type">form</field>
            <field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_form"/>
            <field name="arch" type="xml">
                <field name="account_id" position="replace">
                    <field domain="[('type','=','normal'),('state', '&lt;&gt;', 'close')]" name="account_id" on_change="on_change_account_id(account_id)" select="1"/>
                </field>
            </field>
        </record>

        <record id="hr_timesheet_line_tree" model="ir.ui.view">
            <field name="name">hr.analytic.timesheet.tree</field>
            <field name="model">hr.analytic.timesheet</field>
            <field name="type">tree</field>
            <field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_tree"/>
            <field name="arch" type="xml">
                <field name="amount" position="after">
                    <field name="to_invoice"/>
                </field>
            </field>
        </record>

        <record id="hr_timesheet_line_tree2" model="ir.ui.view">
            <field name="name">hr.analytic.timesheet.tree2</field>
            <field name="model">hr.analytic.timesheet</field>
            <field name="type">tree</field>
            <field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_tree"/>
            <field name="arch" type="xml">

                <field name="account_id" position="replace">
                    <field domain="[('type','=','normal'),('state', '&lt;&gt;', 'close')]" name="account_id" on_change="on_change_account_id(account_id)"/>
                </field>
            </field>
        </record>

        <!-- Inherits for account analytic lines -->
        <record id="view_account_analytic_line_search_inherit" model="ir.ui.view">
            <field name="name">account.analytic.line.search.to_invoice</field>
            <field name="model">account.analytic.line</field>
            <field name="type">search</field>
            <field name="inherit_id" ref="account.view_account_analytic_line_filter"/>
            <field name="arch" type="xml">
                <field name="date" position="before">
                    <filter name="to_invoice" string="To Invoice" context="{'to_invoice': 1}" domain="[('invoice_id','=',False),('to_invoice','&lt;&gt;',False)]" icon="terp-dolar"/>
                    <separator orientation="vertical"/>
                </field>
            </field>
        </record>

        <record id="view_account_analytic_line_tree_inherit" model="ir.ui.view">
            <field name="name">account.analytic.line.tree.to_invoice</field>
            <field name="model">account.analytic.line</field>
            <field name="type">tree</field>
            <field name="inherit_id" ref="account.view_account_analytic_line_tree"/>
            <field name="arch" type="xml">
                <field name="account_id" position="after">
                    <field name="to_invoice"/>
                </field>
            </field>
        </record>
          <record id="view_account_analytic_line_form_inherit" model="ir.ui.view">
            <field name="name">account.analytic.line.form.to_invoice</field>
            <field name="model">account.analytic.line</field>
            <field name="type">form</field>
            <field name="inherit_id" ref="account.view_account_analytic_line_form"/>
            <field name="arch" type="xml">
                <field name="product_uom_id" position="after">
                    <field name="to_invoice"/>
                    <field name="invoice_id"/>
                </field>
            </field>
        </record>

        <!-- Menus -->
        <record id="action_hr_analytic_timesheet_open_tree" model="ir.actions.act_window">
            <field name="name">Bill Tasks Works</field>
            <field name="res_model">account.analytic.line</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="domain">[]</field>
            <field name="context">{'search_default_to_invoice': 1}</field>
 			<field name="search_view_id" ref="account.view_account_analytic_line_filter"/>            
            <field name="help">This list shows you every task you can invoice to the customer. Select the lines and click the Action button to generate the invoices automatically.</field>
        </record>
        <menuitem
            action="action_hr_analytic_timesheet_open_tree"
            id="menu_hr_analytic_timesheet_tree"
            parent="account.menu_finance_periodical_processing_billing"
            sequence="1"/>

        <record id="view_hr_timesheet_invoice_factor_search" model="ir.ui.view">
            <field name="name">hr_timesheet_invoice.factor.search</field>
            <field name="model">hr_timesheet_invoice.factor</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Type of invoicing">
                    <group>
                        <field name="name"/>
                    </group>
                </search>
            </field>
        </record>
        <record id="view_hr_timesheet_invoice_factor_form" model="ir.ui.view">
            <field name="name">hr_timesheet_invoice.factor.form</field>
            <field name="model">hr_timesheet_invoice.factor</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Type of invoicing">
                    <field colspan="1" name="name"/>
                    <field colspan="1" name="customer_name"/>
                    <field colspan="2" name="factor"/>
                </form>
            </field>
        </record>
        <record id="view_hr_timesheet_invoice_factor_tree" model="ir.ui.view">
            <field name="name">hr_timesheet_invoice.factor.tree</field>
            <field name="model">hr_timesheet_invoice.factor</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Types of invoicing">
                    <field name="name"/>
                    <field name="customer_name"/>
                    <field name="factor"/>
                </tree>
            </field>
        </record>
        <record id="action_hr_timesheet_invoice_factor_form" model="ir.actions.act_window">
            <field name="name">Types of Invoicing</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">hr_timesheet_invoice.factor</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="view_hr_timesheet_invoice_factor_tree"/>
            <field name="search_view_id" ref="view_hr_timesheet_invoice_factor_search"/>
            <field name="help">OpenERP allows you to create default invoicing types. You might have to regularly assign discounts because of a specific contract or agreement with a customer. From this menu, you can create additional types of invoicing to speed up your invoicing.</field>
        </record>
        <menuitem
            action="action_hr_timesheet_invoice_factor_form"
            id="hr_timesheet_invoice_factor_view"
            parent="account.menu_configuration_misc" sequence="25"/>

    </data>
</openerp>
