Skip to Content
Menu
This question has been flagged
2 Replies
2283 Views

I need help somebody. i am new to odoo and i started with odoo 9. I have been learning about inheritance and extending views which works for the most part, however this one time, i cannot see my custom field being extended on the product form.

The field appears clearly in the product.product model, but appears there is a lock on displaying it on the product template form. 

Any help is greatly appreciated.

Here is my code:

<record id="product_product_template_only_form_view" model="ir.ui.view">
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<field name="list_price" position="before">
<field name="rentaloptions_id"/>
</field>
</field>
</record>

 class product_product(models.Model):

    _inherit = 'product.product'
rentaloptions_id = fields.Many2one('product.category','Rental Options')

Avatar
Discard
Best Answer

First of all make sure that your module depends on the 'product' module. You can check this in your "__openerp__.py" file in the line depends = ['base','product']. After that make sure that in your models/models.py you are inheriting the 'product.template' and not 'product.product'. Because in the Sales --> Products, the model is product.template.

It is good to note that if you are going to create a sale order from python code with self.env.create(vals) the product.product will be used. But if you are going to create or modify the fields of the products the correct model to use is product.templ

Now in the view also the <field name="model">product.product</field> 
should be <field name="model">product.template</field>
Also check here and change it to product.template:



_inherit = 'product.template'
rentaloptions_id = fields.Many2one('product.category','Rental Options')

Hope this answers your question.

Riste Kabranov,

Python/Odoo Developer

@ NEBIZ IT DOOEL 

Avatar
Discard
Best Answer

Hi,

The ID if template you are inheriting is of model product.template not product.product

Also make sure that xml record is defining the field list_price. If some other record inherits it and define list_price then you should inherit the second record.

Avatar
Discard