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

Trying to add fields to sale order form view give "AssertionError: Element openerp has extra content"

By
Andrea Mazzacani
on 11/3/16, 3:42 AM 212 views

Hi all, I'm new in odoo development and i can't see the error in my code.

stack trace:

2016-11-03 07:26:07,201 1468 INFO BOMBO openerp.tools.convert: file:///C:/ODOO/server/openerp/addons/bomboneria_carla_new/views/bomboneria_sale_order.xml:3:0:ERROR:RELAXNGV:RELAXNG_ERR_EXTRACONTENT: Element openerp has extra content: 
data2016-11-03 07:26:07,203 1468 ERROR BOMBO openerp.modules.registry: Failed to load registryTraceback (most recent call last):
File "C:\ODOO\server\.\openerp\modules\registry.py", line 385, in new
File "C:\ODOO\server\.\openerp\modules\loading.py", line 338, in load_modules
File "C:\ODOO\server\.\openerp\modules\loading.py", line 237, in load_marked_modules
File "C:\ODOO\server\.\openerp\modules\loading.py", line 156, in load_module_graph
File "C:\ODOO\server\.\openerp\modules\loading.py", line 98, in _load_data
File "C:\ODOO\server\.\openerp\tools\convert.py", line 852, in convert_file
File "C:\ODOO\server\.\openerp\tools\convert.py", line 926, in convert_xml_import
File "lxml.etree.pyx", line 3313, in lxml.etree._Validator.assert_ (src\lxml\lxml.etree.c:159862)
AssertionError: Element openerp has extra content: data, line 3



My files:

bomboneria_sale_order.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="sale_order_form_view_inherit" model="ir.ui.view" >
<field name="name">sale.order.form.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml" >
<!-- <xpath expr="//field[@name='template_id']" position="after">
<field name="activity_scope"/> </xpath> -->
</field>
</record>
</data>
</openerp>

bomboneria_sale_order.py

# -*- coding: utf-8 -*-# Copyright 2016 Omnia Sistemi# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import api, fields, models

class bomboneria_sale_order(models.Model):
     _inherit = 'sale.order'
_description = 'Ordine Bomboneria'
 _name = 'bomboneria.sale.order'

ceremony_type = fields.Selection([ ('1','Battesimo'), ('2','Crescita'), ('3','Comunione'), ('4','Matrimonio'), ('5','Festa'), ('6','Altro'), ], string = "Tipo di Evento", help = "Tipo di Evento")
down_payment = fields.Char(string = "Acconto", help = "Acconto")
delivery_extimated_date = fields.Date(string = "Data prevista Consegna", help = "Data prevista Consegna")

Could you please provide your openerp file? Then I can test it

Nilmar Shereef
on 11/3/16, 5:08 AM

Added openerp in my answer :)

Andrea Mazzacani
on 11/3/16, 5:26 AM

class bomboneria_sale_order(models.Model):

_inherit = 'sale.order'

_description = 'Ordine Bomboneria'

_name = 'bomboneria.sale.order'

Use '_name" for model naming

Nilmar Shereef
on 11/3/16, 5:34 AM

Ah sorry that was a copy/paste error. I used _name in .py file. Odoo.com don't let me modify original post

Andrea Mazzacani
on 11/3/16, 5:40 AM

I constructed a module with your fields in Sale Order.

it works fine. Could you please try omitting _name , _description from py file

Nilmar Shereef
on 11/3/16, 5:47 AM

Same error :| . I tried installing module without view and works fine. All fields are added in sale.order. After that I tried to install module with xml file with tag <openerp> and <data> and work fine. When i add the <record> tag i get error. It is odoo 9.0 on a windows server machine.

Andrea Mazzacani
on 11/3/16, 6:05 AM

Thank you for all your help. I tried removing _name and _description and still install it. I always get the problem when i try to inherit the sale.order form view. Have you used my xml code? I can't comment your reply, more karma needed.

Andrea Mazzacani
on 11/3/16, 6:27 AM

Please have a look to my answer, I will attach my xml inside my answer

Nilmar Shereef
on 11/3/16, 6:33 AM

It works! Thank You! You just made my day! but i still can't notice why mine is wrong... any ideas?

Andrea Mazzacani
on 11/3/16, 6:46 AM

I think your xml id may raise the issue. Anyway thanks :)

Nilmar Shereef
on 11/3/16, 6:55 AM
6

Nilmar Shereef

--Nilmar Shereef--
811
| 4 3 7
Calicut, India
--Nilmar Shereef--

Python Developer. Android Developer. .Net Developer

Nilmar Shereef
On 11/3/16, 4:30 AM

Hi Andrea Mazzacani,
    I did the module with your fields, Please avoid _name, _description from your code. Also you wrote 'name' instead of _name. That may be issue. So please try  by deleting existing  one. Also ensure your mentioned fields are present in sale_order_form.


XML file:


<?xml version="1.0" encoding="UTF-8"?>

<openerp>   

    <data>       

        <record id="sale_order_form_view_inher_c5" model="ir.ui.view" >            

        <field name="name">sale.order.oca.test3</field>           

        <field name="model">sale.order</field>           

        <field name="inherit_id" ref="sale.view_order_form"/>           

        <field name="arch" type="xml" >               

            <xpath expr="//field[@name='partner_id']" position="after">                       

                <field name="ceremony_type"/>                       

                <field name="down_payment"/>                       

                <field name="delivery_extimated_date"/>               

            </xpath>           

           </field>       

        </record>   

    </data>

</openerp>

0
Andrea Mazzacani
On 11/3/16, 4:46 AM

Hi Nilmar Shereef,

Thank you but I just tried your solution and  give the same result.  :/ I already did something similar in another module for res.partner without problems. Let's hope someone notice what's wrong.  :)

__openerp__.py

# -*- coding: utf-8 -*-
{
'name': 'Bomboneria Carla',
'description': """
Personalizzazioni Bomboneria Carla""",
'version': '10.0.1.0.0',
'license': 'AGPL-3',
 'author': 'Omnia Sistemi',
'depends': [
 'base',
 'sale',
 ],
 'data': [
 'views/bomboneria_sale_order.xml',
 ],
}

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

1 follower(s)

Stats

Asked: 11/3/16, 3:42 AM
Seen: 212 times
Last updated: 11/3/16, 6:44 AM