Translated copy of http://planet.domsense.com/2012/01/openerp-new-web-client-6-1-javascript-hooks/

I was trying to run my office at the time of logout, but my code was never executed and I could not understand why.
Here’s how you can “easily” place your handler for a particular event (an event-specific ERP, on_logout type) as follows:

openerp.yourmodule = function (OpenERP) {
openerp.webclient.on_logout.add_first (
function () {
alert ('thatsme!');

You should be aware of two things in particular:

  1. you must use “openerp.webclient” and not “openerp.web.WebClient” (in reality are aliases, but the second is not available)
  2. you must use the real name of your form so that your JS is loaded

Actually the last point is one of the few information you find in the not-so-official documentation of the web form ( read my last post to know how to get it ).
Using “add_first” I added a handler for the event “on_logout” that will run before any other handler exists.
Looking at the original code module you will find other “hooks” such as “add_last” which in turn puts your handler at the end of the run queue.