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 solve "AssertionError: Expecting element openerp, got record, line 1" ?

By
Chris Keen
on 11/21/14, 6:09 AM 3,104 views

I am relative new to Odoo, a great set of applications.

I am trying to build a custom module that extends res.partner. (test environment: Windows 8 local install - Odoo v8 latest 19 nov.)

The extra fields are added to the model but the view fails to install with the following message

Expecting element openerp, got record, line……

Traceback (most recent call last): File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\http.py", line 500, in _handle_exception File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\http.py", line 517, in dispatch File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\http.py", line 283, in _call_function File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\service\model.py", line 113, in wrapper File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\http.py", line 280, in checked_call File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\http.py", line 733, in __call__ File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\http.py", line 376, in response_wrap File "C:\Program Files (x86)\Odoo 8.0\server\openerp\addons\web\controllers\main.py", line 952, in call_button File "C:\Program Files (x86)\Odoo 8.0\server\openerp\addons\web\controllers\main.py", line 940, in _call_kw File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\api.py", line 237, in wrapper File "C:\Program Files (x86)\Odoo 8.0\server\openerp\addons\base\module\module.py", line 450, in button_immediate_install File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\api.py", line 237, in wrapper File "C:\Program Files (x86)\Odoo 8.0\server\openerp\addons\base\module\module.py", line 498, in _button_immediate_function File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\modules\registry.py", line 341, in new File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\modules\loading.py", line 358, in load_modules File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\modules\loading.py", line 263, in load_marked_modules File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\modules\loading.py", line 182, in load_module_graph File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\modules\loading.py", line 118, in _load_data File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\tools\convert.py", line 897, in convert_file File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\tools\convert.py", line 974, in convert_xml_import File "lxml.etree.pyx", line 3313, in lxml.etree._Validator.assert_ (src\lxml\lxml.etree.c:159862) AssertionError: Expecting element openerp, got record, line 1

Here is my module code

from openerp.osv import osv, fields

class extend_partner(osv.Model):
    _inherit = 'res.partner'
    _columns = {
        'x_field1' : fields.date('Field 1'),
        'x_field2' : fields.integer('Field 2', size=11)
        }

Here is my view XML

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="extend_partner_view" model="ir.ui.view">
            <field name="name">res.partner.form</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form"/>
            <field name="arch" type="xml">
                <xpath expr="/form/sheet/group/group/field[@name='website']" position="after">
                    <field name="x_field1"/>
                    <field name="x_field2"/>
                </xpath>
            </field>
        </record>
    </data>
</openerp>

 

Any ideas what I'm doing wrong.

Thanks in advance...

Chris

 

 

0

Leonardo Donelli

--Leonardo Donelli--
1040
| 5 4 8
Cave, Italy
--Leonardo Donelli--

Physics student and part-time developer.

Leonardo Donelli
On 11/21/14, 8:12 AM

Based on the fact that it says the record element is on line 1, it could be a problem of "wrong newlines", i.e. Windows-style line terminators instead of Unix Style. Assure you have Unix style newlines with your editor.

-1

Ludo - Neobis

--Ludo - Neobis--
2387
| 2 2 5
Hoogvliet, Netherlands
--Ludo - Neobis--

Developer

Ludo - Neobis
On 11/21/14, 6:26 AM

Shouldn't it be "osv.osv" or "models.Model" as class inheritence? Since your import is going for osv, I was expeciting "osv.osv".

Thanks Ludo, Do you mean in the module code? from openerp.osv import osv, fields class extend_partner(osv.Model): should be from openerp.osv import osv, fields class extend_partner(osv.osvl):

Keen Intelligence, Chris Keen
on 11/21/14, 6:38 AM

That is what I meant indeed. Not quite sure if that causes the error, but I haven't seen the construction you posted, so that's why I got triggered.

Ludo - Neobis
on 11/21/14, 6:42 AM

osv.osv has been deprecated for a long time. You should use from openerp.osv import orm; class myclass(orm.Model) for v7 API.

Leonardo Donelli
on 11/21/14, 8:06 AM

I'm using v8. I've seen so many versions and coding? Thanks

Keen Intelligence, Chris Keen
on 11/21/14, 8:19 AM

If you use the new API, you should use "from openerp import models; class my_class(models.Model) If you are using the old API you should use "from openerp.osv import orm; class my_class(orm.Model) "osv.osv" is a very deprecated way (you can see it's a lot less clear than "orm.Model"), and so is "osv.Model". See https://github.com/odoo/odoo/blob/7.0/openerp/osv/osv.py#L232

Leonardo Donelli
on 11/21/14, 8:27 AM

The field has been added to the model but now I get aan invalid view error ParseError: "ValidateError Field(s) `arch` failed against a constraint: Invalid view definition Error details: Element '<xpath expr="/form/sheet/group/group/div/field[@name='website']">' cannot be located in parent view Error context: View `res.partner.form` [view_id: 349, xml_id: n/a, model: res.partner, parent_id: 126]" while parsing file:///C:/Program Files (x86)/Odoo 8.0/server/openerp/addons/extend_partner/extend_partner_1_view.xml:4, near res.partner.form res.partner <xpath expr="/form/sheet/group/group/div/field[@name='website']" position="after"> I'm begiining to loose hope

Keen Intelligence, Chris Keen
on 11/21/14, 8:27 AM

What field? Nobody said anything about a field here. Please check and try my answer.

Leonardo Donelli
on 11/21/14, 8:30 AM

Thanks, I will use it next time, as the field is already added to the partner model. But now the path in the view definition is wrong! Element '<xpath expr="/form/sheet/group/group/div/field[@name='website']">' . Do I need to include the 'div' (in the standard res.partner.form) or is the view xml laso wrong? res.partner.form res.partner <xpath expr="/form/sheet/field[@name='name']" position="after">

Keen Intelligence, Chris Keen
on 11/21/14, 8:37 AM

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: 11/21/14, 6:09 AM
Seen: 3104 times
Last updated: 3/16/15, 8:10 AM