I was trying to inject some custom code on logout event. My code was never executed though. Finally I got it working thanks to Xavier Morel (see my question on stackoverflow).
Here is the clue: you can “easily” inject an handler for a given event (openerp-web specific ones) by doing like this:
openerp.yourmodule = function(openerp) { openerp.webclient.on_logout.add_first( function () { alert('thatsme!'); } ); }
You must pay attention to 2 things particularly:
- you MUST use “openerp.webclient” and not “openerp.web.WebClient”
- you MUST use your module name in order to get the JS loaded
This last point is among the few informations you find in the not-so-official docs contained into the web module (see my previous blogpost on how to get them).
Using “add_first” I’m adding an event handler for the logout event which will be executed before any existing handler.
If you look at the original code of the web module you’ll find other “hooks” like “add_last” which in turns add your handler at the end of the queue.