First, I created the class 'product_template' inherit to add the field 'new_field'
class product_template(osv.osv):
_name = 'product.template'
_inherit = 'product.template'
_columns = {
'new_field': fields.many2one('product.uom','Unité de Stockage',required=True, ondelete='cascade'),
}
product_template()
After, the xml
<record id="purchase_order_form" model="ir.ui.view">
<field name="name">purchase_order_form</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form" />
<field eval="90" name="priority"/>
<field name="arch" type="xml"><xpath expr="/form[@string='Purchase Order']/sheet/notebook/page[@string='Products']/field[@name='order_line']/tree[@string='Purchase Order Lines']/field[@name='price_unit']" position="before">
<field name="new_field_po" string="U Stock"/>
</xpath>
</field>
</record>
And the new py
class purchase_order_line(osv.osv):
_name = 'purchase.order.line'
_inherit = 'purchase.order.line'
_columns = {
'new_field_po': fields.related('product','new_field',type='many2one',relation='product.product',string='Title',store=True),
The creation of new_field is correct in the product_template.
But when I create a PO, this does not work, the line does not take the value of the field, it remains empty