Hi,
I'm new in OpenERP web module development and I'm currently trying to make a simple module that just display a button, and if I clic the button I want javascript to write a message in the developper console of my browser.
I am following a tutorial : doc.openerp.com/trunk/developers/web/module/
But it doesn't work, and I'm not understanding what I made wrong.
I have the following files :
web_example
├── __init__.py
├── __openerp__.py
├── web_example.xml
├── static
├── src
└── js
└── first_module.js
__init__.py is empty
__openerp__.py
{
'name': "Web Example",
'description': "Basic example of a (future) web module",
'category': 'Hidden',
'depends': ['web'],
'data': ['web_example.xml'],
'js': ['static/src/js/first_module.js'],
}
web_example.xml
Example Client Action example.action
first_module.js
openerp.web_example = function (instance) {
instance.web.client_actions.add('example.action', 'instance.web_example.action');
instance.web_example.action = function (parent, action) {
console.log("Executed the action", action);
};
};
According to the tutorial, this code should make a button in the menu, and if you click the button you get a message in the console.
My problem is that when I try to upgrade my module i get errors :
AssertionError: No window action defined for this id action_client_example !
Verify that this is a window action or add a type argument.
And here is the complete log :
OpenERP Server Error
Client Traceback (most recent call last):
File "/opt/openerp/server/openerp/addons/web/common/http.py", line 180, in dispatch
response["result"] = method(controller, self, **self.params)
File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 1004, in call_button
action = self.call_common(req, model, method, args, domain_id, context_id)
File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 948, in call_common
return self._call_kw(req, model, method, args, {})
File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 962, in _call_kw
return getattr(req.session.model(model), method)(*args, **kwargs)
File "/opt/openerp/server/openerp/addons/web/common/openerplib/main.py", line 250, in proxy
args, kw)
File "/opt/openerp/server/openerp/addons/web/common/openerplib/main.py", line 117, in proxy
result = self.connector.send(self.service_name, method, *args)
File "/opt/openerp/server/openerp/addons/web/common/http.py", line 611, in send
raise fault
Server Traceback (most recent call last):
File "/opt/openerp/server/openerp/addons/web/common/http.py", line 592, in send
result = openerp.netsvc.dispatch_rpc(service_name, method, args)
File "/opt/openerp/server/openerp/netsvc.py", line 360, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "/opt/openerp/server/openerp/service/web_services.py", line 569, in dispatch
security.check(db,uid,passwd)
File "/opt/openerp/server/openerp/service/security.py", line 40, in check
pool = pooler.get_pool(db)
File "/opt/openerp/server/openerp/pooler.py", line 50, in get_pool
return get_db_and_pool(db_name, force_demo, status, update_module)[1]
File "/opt/openerp/server/openerp/pooler.py", line 33, in get_db_and_pool
registry = RegistryManager.get(db_name, force_demo, status, update_module, pooljobs)
File "/opt/openerp/server/openerp/modules/registry.py", line 138, in get
update_module, pooljobs)
File "/opt/openerp/server/openerp/modules/registry.py", line 160, in new
openerp.modules.load_modules(registry.db, force_demo, status, update_module)
File "/opt/openerp/server/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/openerp/server/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/openerp/server/openerp/modules/loading.py", line 193, in load_module_graph
load_data(module_name, idref, mode)
File "/opt/openerp/server/openerp/modules/loading.py", line 92, in
load_data = lambda *args: _load_data(cr, *args, kind='data')
File "/opt/openerp/server/openerp/modules/loading.py", line 138, in _load_data
tools.convert_xml_import(cr, module_name, fp, idref, mode, noupdate, report)
File "/opt/openerp/server/openerp/tools/convert.py", line 997, in convert_xml_import
obj.parse(doc.getroot())
File "/opt/openerp/server/openerp/tools/convert.py", line 890, in parse
self._tags[rec.tag](self.cr, rec, n)
File "/opt/openerp/server/openerp/tools/convert.py", line 632, in _tag_menuitem
"Verify that this is a window action or add a type argument." % (a_action,)
AssertionError: No window action defined for this id action_client_example !
Verify that this is a window action or add a type argument.
So my question is
What am I doing wrong ?
Is there another way to just get a button that trigger javascript action ?
Thanks.
↧