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

I am trying to create a small addon which would add a field to the product.template class and display it on the product form after the 'barcode' field.  Here are the relevant portions of the files.

__init__.py
from . import controllers
from . import models
from . import product

__manifest__.py
'depends': ['base','product'],
'data': [
    'views/views.xml'
    'views/templates.xml',
],

models.py
from odoo import models, fields, api
class ProductTemplateInherited(models.Model):
    _inherit = 'product.template'

   odsp_id = fields.Char(string='ODSP ID')

views.xml
<odoo>
    <data>
        <!--- Inherit the product template form view -->
        <record id="product_template_only_form_view_custom" model="ir.ui.view">
            <field name="name">product.template.custom.form.inherited</field>
            <field name="model">product.template</field>
            <field name="inherited_id" ref="product.product_template_only_form_view"/>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='barcode']" position="after">
                    <field name="odsp_id"/>
                </xpath>
            </field>
        </record>
    </data>
</odoo>


When I try to install the addon, the traceback error report says that field 'odoo_id' does not exist.  What steps am I missing here?

Avatar
Discard
Best Answer

Hi,

I found an error in your code. please correct that. maybe the issue will be solved.

Change this line.

<field name="inherit_id" ref="product.product_template_only_form_view"/>

it is inherit_id not inherited_id

Thank you.

Avatar
Discard
Author

When I do that, I receive a traceback:

ParseError: "External ID not found in the system: product.prodcut_template_only_form_view" while parsing /usr/local/odoo.bak/addons/custon_1/views/views.xml:5, near

Best Answer

Did you restart Odoo? When changing the models, a restart of Odoo is recommended.

Avatar
Discard
Related Posts Replies Views Activity
3
Nov 18
2748
1
Mar 15
3024
1
Aug 24
270
1
Jun 22
1297
3
Dec 23
27549