<?xml version="1.0"?>
<openerp>
  <data>

    <record model="ir.ui.view" id="view_order_form_inherit">
        <field name="name">sale.order.form.inherit</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
            <field name="project_id" position="replace"/>
        </field>
    </record>

    <record model="ir.ui.view" id="view_order_form_inherit2">
        <field name="name">sale.order.form.inherit2</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
           <xpath expr="//field[@name='order_line']/form//field[@name='tax_id']" position="after">
               <field name="analytics_id" domain="[('plan_id','&lt;&gt;',False)]" groups="analytic.group_analytic_accounting"/>
           </xpath>
        </field>
    </record>

    <!-- the presence of 'analytics_id' makes the order lines non-editable -->
    <record id="sale.view_order_form_editable_list" model="ir.ui.view">
        <field name="groups_id" eval="[(4, ref('analytic.group_analytic_accounting'))]"/>
    </record>

    <record model="ir.ui.view" id="view_order_line_form2_inherit">
        <field name="name">sale.order.line.form2.inherit</field>
        <field name="model">sale.order.line</field>
        <field name="inherit_id" ref="sale.view_order_line_form2"/>
        <field name="arch" type="xml">
            <field name="product_id" position="after">
                <field name="analytics_id" domain="[('plan_id','&lt;&gt;',False)]" groups="analytic.group_analytic_accounting"/>
            </field>
        </field>
    </record>


    <!-- Replace analytic_id with analytics_id in account.invoice.line -->

    <record model="ir.ui.view" id="view_invoice_line_form_inherit">
        <field name="name">account.invoice.line.form.inherit</field>
        <field name="model">account.invoice.line</field>
        <field name="inherit_id" ref="account.view_invoice_line_form"/>
        <field name="arch" type="xml">
            <field name="account_analytic_id" position="replace">
                <field name="analytics_id" context="{'journal_id':parent.journal_id}" domain="[('plan_id','&lt;&gt;',False)]" groups="analytic.group_analytic_accounting"/>
            </field>
        </field>
    </record>

    <record model="ir.ui.view" id="view_invoice_form_analytic_inherit">
        <field name="name">account.invoice.form.analytic.inherit</field>
        <field name="model">account.invoice</field>
        <field name="inherit_id" ref="account.invoice_form"/>
        <field name="arch" type="xml">
            <field name="account_analytic_id" position="replace">
                <field name="analytics_id" context="{'journal_id':parent.journal_id}" domain="[('plan_id','&lt;&gt;',False)]" groups="analytic.group_analytic_accounting"/>
            </field>
        </field>
    </record>


  </data>
</openerp>
