How to inherit Sale Order line in odoo


.py file

class sale_line(osv.osv):
 _inherit="sale.order.line"
 def _getcost(self,cr,uid,ids,name,arg,context=None):
 res = {}
 for resource in self.browse(cr,uid,ids,context=context):
 res[resource.id]= resource.product_id.standard_price
 return res
 _columns ={
 'standard_price':fields.function(_getcost,'standard_price',type='char')
 }

.xml file

<record id="sale_view_order_line_form" model="ir.ui.view">
 <field name="name">Sale Order Line</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="standard_price" string="Cost"/>
 </xpath>
 </field>
 </record>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s