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
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
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>
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
0
thg 3 15
|
4830 | ||
|
1
thg 10 24
|
1074 | ||
|
7
thg 12 21
|
10695 | ||
|
0
thg 9 21
|
1246 | ||
|
1
thg 3 15
|
5030 |