I get an error while trying to create my own module.
The error appears when I try to install the module (from a tutorial). I think it is to do with the xml file test.xml. But I just cannot see the error in it. Please help. I am using OpenERP version 6.1.1 (I cannot upgrade for now). Thank you. Here is the error output:
Client Traceback (most recent call last):
File "/opt/OpenObject/openerp-6.1-1/openerp/addons/web/common/http.py", line 180, in dispatch
response["result"] = method(controller, self, *self.params)
File "/opt/OpenObject/openerp-6.1-1/openerp/addons/web/controllers/main.py", line 498, in authenticate
req.session.authenticate(db, login, password, env)
File "/opt/OpenObject/openerp-6.1-1/openerp/addons/web/common/session.py", line 73, in authenticate
uid = self.proxy('common').authenticate(db, login, password, env)
File "/opt/OpenObject/openerp-6.1-1/openerp/addons/web/common/openerplib/main.py", line 117, in proxy
result = self.connector.send(self.service_name, method, *args)
File "/opt/OpenObject/openerp-6.1-1/openerp/addons/web/common/http.py", line 608, in send
raise xmlrpclib.Fault(openerp.tools.exception_to_unicode(e), formatted_info)
Server Traceback (most recent call last):
File "/opt/OpenObject/openerp-6.1-1/openerp/addons/web/common/http.py", line 593, in send
return openerp.netsvc.dispatch_rpc(service_name, method, args)
File "/opt/OpenObject/openerp-6.1-1/openerp/netsvc.py", line 360, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "/opt/OpenObject/openerp-6.1-1/openerp/service/web_services.py", line 397, in dispatch
return fn(params)
File "/opt/OpenObject/openerp-6.1-1/openerp/service/web_services.py", line 408, in exp_authenticate
res_users = pooler.get_pool(db).get('res.users')
File "/opt/OpenObject/openerp-6.1-1/openerp/pooler.py", line 50, in get_pool
return get_db_and_pool(db_name, force_demo, status, update_module)[1]
File "/opt/OpenObject/openerp-6.1-1/openerp/pooler.py", line 33, in get_db_and_pool
registry = RegistryManager.get(db_name, force_demo, status, update_module, pooljobs)
File "/opt/OpenObject/openerp-6.1-1/openerp/modules/registry.py", line 180, in get
update_module, pooljobs)
File "/opt/OpenObject/openerp-6.1-1/openerp/modules/registry.py", line 202, in new
openerp.modules.load_modules(registry.db, force_demo, status, update_module)
File "/opt/OpenObject/openerp-6.1-1/openerp/modules/loading.py", line 334, in load_modules
processed = load_marked_modules(cr, graph, states_to_load, force, status, report, loaded_modules)
File "/opt/OpenObject/openerp-6.1-1/openerp/modules/loading.py", line 253, in load_marked_modules
loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules)
File "/opt/OpenObject/openerp-6.1-1/openerp/modules/loading.py", line 193, in load_module_graph
load_data(module_name, idref, mode)
File "/opt/OpenObject/openerp-6.1-1/openerp/modules/loading.py", line 92, in <lambda>
load_data = lambda *args: _load_data(cr, *args, kind='data')
File "/opt/OpenObject/openerp-6.1-1/openerp/modules/loading.py", line 138, in _load_data
tools.convert_xml_import(cr, module_name, fp, idref, mode, noupdate, report)
File "/opt/OpenObject/openerp-6.1-1/openerp/tools/convert.py", line 988, in convert_xml_import
relaxng.assert_(doc)
File "lxml.etree.pyx", line 3016, in lxml.etree._Validator.assert_ (src/lxml/lxml.etree.c:125483)
AssertionError: Did not expect element templates there, line 2
---------------------------------------------------------------------------
Below are the contents of my files
addons/web_example/__init__.py:
#!/usr/bin/python
++++++++++++++++++++++++++++++++++++++++++++++
addons/web_example/__openerp__.py:
{
'name': "Web Example",
'category': "Hidden",
'description':"A basic web example module",
'depends': ['web'],
'data':["static/xml/test.xml",'web_example.xml'],
'js': ["static/openerp/first_module.js"],
}
++++++++++++++++++++++++++++++++++++++++++++++
addons/web_example/web_example.xml:
<?xml version="1.0" encoding="utf-8" ?>
<openerp>
<data>
<record model="ir.actions.act_window" id="action_client_example">
<field name="name">web_example_class</field>
<field name="res_model">web_example_class</field>
<!--<field name="tag">example.action</field>-->
</record>
<record model="ir.ui.view" id="test_form_view">
<field name="name">test.form</field>
<field name="model">web_example_class</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="test">
<field name="numero" widget="test" />
</form>
</field>
</record>
<menuitem name="WEB EXAMPLE" action="action_client_example" id="menu_client_example"/>
</data>
</openerp>
++++++++++++++++++++++++++++++++++++++++++++++
addons/web_example/static/openerp/first_module.js:
alert("Before function");
openerp.web_example = function(openerp){
openerp.web.form.widgets.add('test','openerp.web.form.test');
openerp.web.form.test = openerp.web.form.FieldChar.extend(
{
template:'test_button',
init: function(){
this._super.apply(this,arguments);
this._start = null;
console.log('INIT');
},
start: function(){
console.log('START');
$('button#bstart').click(this.myfunction);
},
myfunction:function(){
alert("moja funkcja");
console.log("From function");
}
}
)
};
alert("After fnction");
++++++++++++++++++++++++++++++++++++++++++++++
addons/web_example/static/xml/test.xml:
<?xml version="1.0" encoding="utf-8" ?>
<templates>
<div t-name="test_button" t-attf-class="base #{cls}" class="oe_web_example">
<p>
<button name="dosomething" type="button" id="bstart">start</button>
</p>
</div>
</templates>
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
Files that contains qweb templates are placed under qweb
in __openerp__.py
file.
Remove test.xml
file from data
and put it in qweb
in __openerp__.py
like this:
'qweb': ['static/xml/test.xml'],
Hope this will solve your problem.
Hi Sudhir. I did as you said and the error message disappeared. Normally this module should have displayed a button, but it doesn't.When I install/update the module, I get the alert messages "Before function" and "After function", but no button is displayed. Would you know what is missing? Thanks once more.
Thanks @sudhir arya This code is very help for me
Hi Borni. Thanks for the link. I am on it right now reading one of the tutorials.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up