OpenERP – new web client (6.1) – javascript hooks

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) {
        function () {

You must pay attention to 2 things particularly:

  1. you MUST use “openerp.webclient” and not “openerp.web.WebClient”
  2. 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.

Facebook Twitter Linkedin Digg Delicious Reddit Stumbleupon Tumblr Posterous Email Snailmail

Written by on Wednesday, January 11th, 2012

  • Onetown

    well, it’s helpful. thanks dude. 

  • Anonymous

    Great help 😉

  • Timothy Solomon

    nifty, where do you put this code tho? As a js file in your module? Is there a naming convention or do you include it in the

    Thanks for sharing!

  • dda

    How can you tell that this is being loaded once you install the module? I tried this example in OpenERP 6.1 with your code above. My file structure is the openerp days link you gave. Thanks.

    • Simone Orsi

      because you’ll get an alert on logout…. be sure you invalidate your browser cache once you installed it.

  • me

    how to make this js function only work in this module.?I mean not A globle function.

  • Cool

    That worked thaks !!

  • Shrikant

    Hello,Can you plz tell me how can i inherit point_of_sale java script in my module?

    openerp.pos_new = function(db) {

    db.point_of_sale = {};

    var module = db.point_of_sale ;

    db.point_of_sale = db.point_of_sale.include({

    get_app_data: function() {





    this is my code but it gives error like ” function not found include for undefined”


    Below code define the website_mail trunk module in openerp

    path for that

    website_mail >static >src >js
    website_mail_editor.js file
    please explain me for following selected source code