1

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
17
  • try to delete the Version="9.0" on form view. Btw, i recommend you to use Api 8 and not old api if you are doing a new module Commented Feb 25, 2016 at 12:12
  • same error....is this old code??? Commented Feb 25, 2016 at 12:37
  • 1
    Yes, it is. Ok, try with good tabulation since record is in the same level as data please, and edit your question with new code btw Commented Feb 25, 2016 at 12:39
  • what should i do?? is their any error in code? Commented Feb 25, 2016 at 12:43
  • No, its just old (search for odoo new api/old api). The error is for another thing in your .xml file, so please try what i said before untill we fix it :) Commented Feb 25, 2016 at 12:45

7 Answers 7

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

What @yucer answered worked for me, in Odoo v10 I was getting Element odoo has extra content: template, line 3 and the problem was the parameter of a XML tag, in my case I had written inherit instead of inherit_id.
2

there is a spelling mistake in .py file and form view .....

_coloums --> _columns

.py file --> 

_columns = 
{ '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),
}

<!--Form -->

<record id="view_daily_transaction_form" **module**="ir.ui.view"> 
<record id="view_daily_transaction_form" **model**="ir.ui.view"> 

I hope this Answer is helpful for you.. Thank you

Comments

0

In daily_transaction.py File,

_name= "daily_transaction"

It should be like ,

_name= "daily.transaction"

2 Comments

its giving new error like attribute char not found & module.__init__() takes at most 2 arguments (3 given) like that
finaly.. its installed & menu showed up... but creation & listing causes error
0

If you change any code in .xml file , Save that file and you must restart the server and Upgrade your module so that your edited file is loaded again on the server.

You can upgrade your module by command line as below:

./odoo.py -d db_name -u module_name

Only after upgrading your module the changes will take place.

Comments

0

Most of the time, the problem is caused by misspelling at somewhere, such as the attribute names in the XML tags or tag value is between opening and closing tags but not a field value. Anyway, check it carefully, the errors do not show exactly where the misspelling is.

Comments

0

In your daily_transaction_view.xml line number 3 there is one <data> element.

Odoo is not expecting that in your XML. Remove and try to upgrade your module. It should work.

Comments

0

You made a spelling mistake in the XML file.

It should be model not module:

<record id="view_daily_transaction_form" model="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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.