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

Hello,


I tried to add a custom field to the model product.product but it doesn't  work.

There is no error when i push but the field is not created

See my code below in file product.py :


from odoo import fields, models, api


class Product(models.Model):

    _inherit = 'product.product'    

    s_gabarit_1_pp = fields.Char()


Same code for any model works but not for product.product !?! Is there something special for this model ? I precise that i need to add fields in this model to manage special values for each variant


Hope someone could help me

Vincent

Avatar
Discard
Author Best Answer

I found the problem.

The line "from . import ..." was comment in the __init__.py file!!

Avatar
Discard
Best Answer

you can your custom field in product.product.

you have to write xml also for this,you can refer below example:


<record id="view_product_form_inherit" model="ir.ui.view">
    <field name="name">product.form</field>
    <field name="model">product.product</field>
    <field name="inherit_id" ref="product.product_normal_form_view" />
    <field name="arch" type="xml">
        <xpath expr="//field[@name='categ_id']" position="after">
            <field name="s_gabarit_1_pp" />
        </xpath>
    </field>
</record>

Avatar
Discard
Author

Thank you Nirav for your answer, it was not the problem (see my answer)