Odoo Help

0

How to make a Shortcut for Tab(Notebook) in ODOO9

By
sridhar
on 1/12/16, 1:49 AM 711 views

How to make a Shortcut for Tab(Notebook) here I have 5 notebook I need to control this on button ie. When I click button 3 3rd tab need to open, How to did this...

1

Axel Mendoza

--Axel Mendoza--
12091
| 7 8 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 1/27/16, 3:14 PM

Using a shortcut the extension could be done like this in a js file:

odoo.define('web.aek_shortcuts', function (require) {

"use strict";

var core = require('web.core');

var FormView = require('web.FormView');

var common = require('web.form_common');

var _t = core._t;

var QWeb = core.qweb;

var ctrl_count = 0;

$.ctrl_bind = function(key, namespace, callback, args) {

var ev = 'keydown.'+namespace;

$(document).on(ev, function(e) {

if(!args) args=[]; // IE barks when args is null

console.log(e.keyCode)

if((e.keyCode == key.charCodeAt(0) || e.keyCode == key) && e.ctrlKey) {

callback.apply(this, args);

return false;

}

});

};

$.ctrl_unbind = function(name) {

var ev = 'keydown.'+name;

$(document).off(ev);

};

FormView.include({

init: function(parent, dataset, view_id, options) {

this._super.apply(this, arguments);

this.rendering_engine.handle_common_properties = function($new_element, $node, InvisibilityChanger) {

var str_modifiers = $node.attr("modifiers") || "{}";

var modifiers = JSON.parse(str_modifiers);

var ic = null;

if (modifiers.invisible !== undefined) {

var InvisibilityChangerCls = InvisibilityChanger || common.InvisibilityChanger;

ic = new InvisibilityChangerCls(this.view, this.view, modifiers.invisible, $new_element);

}

$new_element.addClass($node.attr("class") || "");

$new_element.attr('style', $node.attr('style'));

if($node[0].tagName == 'PAGE'){

if($node.attr('context')){

var context = JSON.parse($node.attr('context'));

if(context.shortcut != undefined){

ctrl_count++;

this.ctrl_count = ctrl_count;

$.ctrl_bind(context.shortcut, this.ctrl_count, function() {

$new_element[0].children[0].click();//could be used execute_action() too

});

}

}

}

return {invisibility_changer: ic,};

};

},

destroy: function() {

$.ctrl_unbind(this.ctrl_count);

this._super.apply(this, arguments);

},

});

});

With that code installed you could define your notebook page like this:

<notebook>

<page string="Tab 1" context='{"shortcut": "Y"}'>

...

</page>

</notebook>


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 1/12/16, 1:49 AM
Seen: 711 times
Last updated: 2/1/16, 12:17 AM