Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to add a new field in a class from another which is already inherited ?

By
Maurice Agée
on 9/25/15, 5:47 AM 343 views

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 9/25/15, 5:47 AM
Seen: 343 times
Last updated: 9/25/15, 5:47 AM