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

    <record model="ir.ui.view" id="sale_margin_sale_order">
        <field name="name">sale.order.margin.view.form</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
            <xpath expr="//group[@name='sale_total']" position="after">
                <group name="sale_margin_grp">
                    <field name="margin" widget='monetary' options="{'currency_field': 'currency_id'}" groups="base.group_user"/>
                </group>
            </xpath>
        </field>
    </record>

    <record model="ir.ui.view" id="sale_margin_sale_order_line">
        <field name="name">sale.order.line.margin.view.form</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='price_unit']" position="after">
                <field name="purchase_price" groups="base.group_user"/>
            </xpath>
        </field>
    </record>

    <record model="ir.ui.view" id="sale_margin_sale_order_line_form">
        <field name="name">sale.order.line.tree.margin.view.form</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']/tree//field[@name='price_unit']" position="after">
                <field name="purchase_price" groups="base.group_user"/>
            </xpath>
        </field>
    </record>

</data>
</openerp>
