Odoo Module Development error: AssertionError: Element openerp has extra content: data

Peniel picture Peniel · Feb 25, 2016 · Viewed 11.1k times · Source

I am a newbie in developing Modules for Odoo. I started developing a demo module according to documentation. But its giving error. I will provide you all the files & codes here. someone please help ..

My openerp.py file

# -*- coding: utf-8 -*-
{
    'name': "Daily Transaction Manager",

    'summary': """
        Used For Managing entrys of our daily transactions.""",

    'description': """
        Used For Managing entrys of our daily transactions
    """,

    'author': "Peniel Technology LLC",
    'website': "http://www.penieltech.com.com",

    # Categories can be used to filter modules in modules listing
    # Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml
    # for the full list
    'category': 'manager',
    'version': '1.0',

    # any module necessary for this one to work correctly
    'depends': [],

    # always loaded
    'data': [
        # 'security/ir.model.access.csv',
        'daily_transaction_view.xml',

    ],
    # only loaded in demonstration mode
    'demo': [],
    'installable': True,
    'auto_install':False,
}

My init.py file :-

import daily_transaction

My daily_transaction.py File

from openerp import fields,osv


class daily_transaction(osv.osv):
    _name= "daily_transaction"
    _description= "Daily Transaction"

    _coloums = {
        'subject': fields.char('Subject',size=128,required=True),
        'date' : fields.date('Date',required=True),
        'note' : fields.text('Notes'),
        'amount' : fields.float('Amount',required=True),
        'type' : fields.selection([
            ('transport','Transport'),
            ('household','Household'),
            ('personal','Personal'),
            ], 'Type',required=True),

    }

My daily_transaction_view.xml is like:-

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data>
<!-- Action -->
<record id="action_daily_transaction" model="ir.actions.act_window">
    <field name="name">Daily Transaction </field>
    <field name="res_model">daily.transaction</field>
    <field name="view_type">form</field>
    <field name="view_mode">tree,form</field>
    <field name="search_view_id" eval="False"/>
    <field name="context">{}</field>
    <field name="help">Create new daily trasaction</field>
</record>   

<!-- Menu Code here -->
 <menuitem name="Daily Transaction" id="base.daily_transaction_roof" sequence="60"/>

 <menuitem id="menu_daily_transaction_roof" name="Daily Transaction" parent="base.daily_transaction_roof" sequence="1"/>

 <menuitem action="action_daily_transaction" id="menu_action_daily_transaction" parent="menu_daily_transaction_roof" sequence="20"/>

 <!-- Tree--> 
<record id="view_daily_transaction_tree" model="ir.ui.view">
    <field name="name">daily.transaction.tree</field>
    <field name="model">daily.transaction</field>
    <field name="arch" type="xml">
        <tree string="Daily Transaction">
            <field name="name"/>
            <field name="date"/>
            <field name="type"/>
            <field name="amount"/>


        </tree> 

    </field>    



</record>

<!--Form -->

<record id="view_daily_transaction_form" module="ir.ui.view">
    <field name="name">daily.transaction.form.view</field>
    <field name="model">daily.transaction</field>
    <field name="arch" type="xml">
        <form string="Daily Transaction" >
            <group>
                <field name="name"/>
                <field name="date"/>
                <field name="type"/>
                <field name="amount"/>
                <field name="note"/>

            </group>    

        </form> 

    </field>    


</record>   


    </data>

</openerp>

When I tried to install ,Iam getting the error:

Odoo Server Error
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 643, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 680, in dispatch
    result = self._call_function(**self.params)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 316, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 118, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 309, in checked_call
    result = self.endpoint(*a, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 959, in __call__
    return self.method(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 509, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 896, in call_button
    action = self._call_kw(model, method, args, {})
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 884, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/module.py", line 459, in button_immediate_install
    return self._button_immediate_function(cr, uid, ids, self.button_install, context=context)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/module.py", line 533, in _button_immediate_function
    registry = openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 386, in new
    openerp.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 338, in load_modules
    loaded_modules, update_module)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 237, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 156, in load_module_graph
    _load_data(cr, module_name, idref, mode, kind='data')
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 98, in _load_data
    tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
  File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 851, in convert_file
    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
  File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 925, in convert_xml_import
    relaxng.assert_(doc)
  File "lxml.etree.pyx", line 3373, in lxml.etree._Validator.assert_ (src/lxml/lxml.etree.c:166352)
AssertionError: Element openerp has extra content: data, line 3

Answer

yucer picture yucer · Apr 15, 2016

I got the same error when using a wrong "value" attribute for field:

<field value="myvalue" name="myfield"/>

and I did fix it with:

<field name="myfield">myvalue</field>

Check that all your elements are properly closed.

It seems that the validation error message is not properly shown.