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...
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
Using a shortcut the extension could be done like this in a js file:
With that code installed you could define your notebook page like this: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);
},
});
});
<notebook>
<page string="Tab 1" context='{"shortcut": "Y"}'>
...
</page>
</notebook>
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
AanmeldenGerelateerde posts | Antwoorden | Weergaven | Activiteit | |
---|---|---|---|---|
|
0
mrt. 15
|
4787 | ||
|
1
okt. 24
|
1055 | ||
|
7
dec. 21
|
10655 | ||
|
0
sep. 21
|
1207 | ||
|
1
mrt. 15
|
4993 |