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

ValidateError product inherit

By
Pavel Pavlov
on 9/9/13, 4:48 PM 3,090 views

Hello,

I'm trying to create simple addon to add additional field in the product page in the green area

img59.imageshack.us/img59/7929/lesd.png

So far I've synced latest trunc version to my PyDev ide.
Created database with some data in it and made sure openERP works.
crated new addon folder source/addons/z_fivesol/
with following files:
--->__init__.py

import z_fivesol

--->__openerp__.py

{
    'name': 'Z_FiveSol Customisations',
    'version': '0.1',
    'category': 'Tools',
    'description': """Additional Product fields for internal ref code and external ref code """,
    'author': 'FiveSol',
    'depends': ['sale', 'stock', 'purchase'],
    'data': [
        'z_fivesol_view.xml'
    ],
    'demo': [],
    'test': [],
    'installable': True,
    'auto_install': False,
    'images': [],   
    'css': [],
}

---> z_fivesol.py

from openerp import tools
from openerp.osv import fields, osv<br/>
from openerp.tools.translate import _
class product_product(osv.osv):
    _inherit = 'product.product'
    _name = 'product.product'
    _columns = {
                'zCodeFiveSol' : fields.char('Internal Reference', size=64, select=True),
                'zBaumCode' : fields.char('Internal Reference', size=64, select=True),
                }
product_product()

--->z_fivesol_view.xml

<?xml version="1.0" encoding="utf-8"?> 
<openerp>
    <data>
        <record id="zproduct_normal_form_view" model="ir.ui.view">
            <field name="name">product.normal.form.inherit</field>
            <field name="model">product.product</field>
            <field name="inherit_id" ref="base.view_partner_form"/>
            <field name="arch" type="xml">      
                <field name="default_code" position="after">
                    <field name="zCodeFiveSol"/>
                    <field name="zBaumCode"/>
                </field>
            </field>
        </record>
    </data>
</openerp>

Then I run the openERP trunc(v8) server and try to import my addon... I get quite long stack trace, so I'm adding only the last line, looks like it has the relevant information for my failure...

File "/home/pavel/openERP/v8/source/server/openerp/osv/orm.py", line 1548, in _validate raise except_orm('ValidateError', '\n'.join(error_msgs))
ParseError: "ValidateError
The field(s) 'arch, model' failed against a constraint: The model name does not exist or the view architecture cannot be rendered." while parsing /home/pavel/openERP/v8/source/addons/z_fivesol/z_fivesol_view.xml:4, near <record id="zproduct_normal_form_view" model="ir.ui.view">

I wanted to inherit the product.product model and add two fields to the database, then inherit the product_view.xml-> <page string="Information"> and add those two fields to the product view from the screenshot...
The model product.product exists, so I'd bet that I didn't do properly the naming of the record that I want to modify and the definition of where I want to put the fields... or maybe should have used different names in the .py file... but I found the docu quite confusing and failed to identify my error...Looking forward to your replies. Thank you!

Regards,
Pavel Pavlov

2

Grover Menacho

--Grover Menacho--
2523
| 5 7 8
La Paz, Bolivia
--Grover Menacho--

Systems Engineer + MBA

Grover Menacho
On 9/9/13, 5:36 PM

Actually I couldn't see v8 code, but it seems that you have some mistakes on your code.

1:

    'depends': ['sale', 'stock', 'purchase'],

Add product

2:

<field name="inherit_id" ref="base.view_partner_form"/>

You have to inherit the product view, something like this:

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

I think that it's going to work after this, tell me how it goes.

Hello, Looks like I overlooked when I was copy-pasting and merging different examples.I changed __openerp__.py -> 'depends': ['product', 'sale', 'stock', 'purchase'] and 2. Changed z_fivesol_view.xml <field name="inherit_id" ref="product.product_normal_form_view"/>. This time it imported properly and displayed the fields where I want. Thank you a lot for the prompt response! Regards, Pavel

Pavel Pavlov
on 9/9/13, 5:49 PM

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

2 follower(s)

Stats

Asked: 9/9/13, 4:48 PM
Seen: 3090 times
Last updated: 3/16/15, 8:10 AM