Tuesday 21 February 2017

How to Make Custom Keyboard shortcuts for odoo ?

Here, i will show you some example to get custom shortcuts works in odoo. you can also override default shortcuts in odoo. as you can see for that we have to create one js file in out module. the path of the file is module / static / src / js / file_js.js
and put the below code into file .


$.shortcut = function(key, callback, args) {
    $(document).keydown(function(e) {
        if(!args) args=[]; // IE barks when args is null
        console.log(e.keyCode)
        if((e.keyCode == key.charCodeAt(0) || e.keyCode == key)) {
            callback.apply(this, args);
            return false;
        }
    });
};

                    //Edit the current object F2
$.shortcut('113', function() {
$('.oe_form_button_edit').each(function() {
if($(this).parents('div:hidden').length == 0){
$(this).trigger('click');
}
});
});


with this user can save the record with F2 button.
so as simple way we can also create record, delete record, make tree view to unlimited , remove the filter , open calendar and so many things using key board key.

No comments:

Post a Comment