This question has been flagged
2 Replies
6141 Views

In dashboard view when displaying tree view of a model, I want to allow user to create new line (display create button). I guess this must be done in Javascript but can't figure how.

Thanks for your help

Avatar
Discard
Author Best Answer

Well! here is the steps to achieve it.

1-  Create a web module (see for more details  http://openerp-web-v7.readthedocs.org/en/latest/module.html)

2-  Create a javascript file and copy the lines bellow to it :

    openerp.name_of_your_module = function (instance) {

    instance.web.ViewManagerAction.include({

        init: function(parent, action) {      
            var flags = action.flags || {};

            if (parent.__parentedParent.form_template == 'DashBoard') {
             _.extend(flags, {
                   search_view : false,
                    sidebar : true,
                    views_switcher : false,
                    action_buttons : true,
                    pager: true,
                    low_profile: true,
                    display_title: false,
                    list: {
                        selectable: true
                    }                    
                });

            };
            action.flags = flags;
            this._super(parent, action);
        },
        });    

};

3-  create a css file with this to display the header :

.openerp .oe_dashboard .oe_action .oe_content .oe_view_manager_header {
  display: -webkit-inline-box;
}

 

hope it helps!

Avatar
Discard

I have to create a module as per your instruction ,But I cant see create button in any of Dash Board(like sales,hr,purchase etc. ) This is the module what i Did

In which menu this feature is available,in sale/purchase reporting etc..?

Author

Sorry for late, i was overloaded with work. I test it on a new DB by using your code below and it works fine. You can see that in most reporting menu views, for example "sales/my quotations"

Best Answer

module name-------dashboard_sample

css--

.openerp .oe_dashboard .oe_action .oe_content .oe_view_manager_header {
  display: -webkit-inline-box;
}

js--

openerp.dashboard_sample = function (instance) {

    instance.web.ViewManagerAction.include({

        init: function(parent, action) {      
            var flags = action.flags || {};

            if (parent.__parentedParent.form_template == 'DashBoard') {
             _.extend(flags, {
                   search_view : false,
                    sidebar : true,
                    views_switcher : false,
                    action_buttons : true,
                    pager: true,
                    low_profile: true,
                    display_title: false,
                    list: {
                        selectable: true
                    }                    
                });

            };
            action.flags = flags;
            this._super(parent, action);
        },
        });    

};

init.py,

__openerp__.py-------

{
    'name': "Web Dashboard Example",
    'description': "Basic example of a (future) web module",
    'category': 'Hidden',
    'depends': ['base'],
    'js': ['static/src/js/test.js'],
    'css': ["static/src/css/testval.css"],
}

 

 

 

 

Avatar
Discard