OpenERP web – How to add custom functionalities to the sidebar

Following my recent article on “How to export current ‘tree’ view to XLS: use web_export_view” I’d like to show how you can add more functionalities to your sidebar on OpenERP web 6.1.

The interesting code from web_export_view module looks like this:

//  @@@ web_export_view custom JS @@@

openerp.web_export_view = function(openerp) {

    _t = openerp.web._t;

    openerp.web.Sidebar = openerp.web.Sidebar.extend({

        add_default_sections: function() {
            // IMHO sections should be registered objects
            // as views and retrieved using a specific registry
            // so that we don't have to override this

            var self = this,
            view = this.widget_parent,
            view_manager = view.widget_parent,
            action = view_manager.action;
            if (this.session.uid === 1) {
                this.add_section(_t('Customize'), 'customize');
                this.add_items('customize', [{
                    label: _t("Translate"),
                    callback: view.on_sidebar_translate,
                    title: _t("Technical translation")

            this.add_section(_t('Other Options'), 'other');
            this.add_items('other', [
                    label: _t("Import"),
                    callback: view.on_sidebar_import
                }, {
                    label: _t("Export"),
                    callback: view.on_sidebar_export
                    label: _t("Export current view"),
                    callback: this.on_sidebar_export_view

  1. First  (line 3) define your module’s namespace.
  2. then extend (line 7) the sidebar object
  3. and override ‘add_default_sections’ method (line 9)
  4. then we add our new action with its callback to the ‘other’ section using ‘add_items’ function (line 37)
Unfortunately the sidebar is not so modular at this point. As I commented into the code, if we had a registry for sidebar sections/actions we could just define ours and register it. But, for the time being you’ll need to override the original method and maintain by copy&paste the “real default” sections/actions (for the original one, have a look at the core web module).
If you need help on  how to create your web module, check openerp_bootstrap.
A ‘must-say recommendation’: use Firebug to debug your javascript experiments, it will save you a lot of time 😉
Facebook Twitter Linkedin Digg Delicious Reddit Stumbleupon Tumblr Posterous Email Snailmail

Written by on Monday, June 4th, 2012

  • OpenERP Asia

    Very interesting. We are going to test this very soon. Thanks for the tip.

  • Nhomar Hernandez

    Great Job Dude, You are a GOD 😉

    • Simone Orsi

      Hi Nhomar, to much gracefulness 🙂 tnx

  • Marek

    Hey. Thanks for this article, its very useful, but…. 😉 I need to have my new sidebar button visible just for specific model (like ‘’ for example). Do you know the way how to do it ?

  • Donald

    simahawk, thanks for the tutorials. how can i customize the side bar of the open erp 7 to my own taste step by step if it is OK by you then just the code from the start then to the changes on the browser. if u could help, i would really appreciate here is my mail Expecting your reply

  • HachDev

    how can i create a form or a button in the Website Ecommerce module and control the submit action from the controller