add fields in sale order line code example

Example: add fields in sale order line

For that you need to inherit sale.order.line object and use
xpath to display in sale order form view. 

In PY:-

class SaleOrderLine(models.Model):

     _inherit = 'sale.order.line'



     x_field = fields.Char('X Field')



In Xml:-

<record model="ir.ui.view" id="sale_order_view_inherit">
    <field name="name">sale.order.view.inherit1</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">
        <xpath expr="/form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='name']" position="after">
            <field name="x_field"/>
        </xpath>
    </field>
</record>



This fields shows after Description in the sale order line.



Hope it will helps you.

Thanks,

Tags:

Misc Example