How to add a shortcut key for Add an item button, if i have a 50 line item so i need shortcut for this in enter button to how to acheive this, kindly share me a suggestion.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
4
Replies
3373
Views
try this code in a loaded js file:
odoo.define('web.aek_shortcuts', function (require) {
"use strict";
var core = require('web.core');
var form_widgets = require('web.form_widgets');
var FieldOne2Many = core.form_widget_registry.get('one2many');
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);
};
FieldOne2Many.include({
init: function() {
var self = this;
this._super.apply(this, arguments);
var context = this.dataset.context.eval();
if(context.shortcut != undefined){
ctrl_count++;
self.ctrl_count = ctrl_count;
$.ctrl_bind(context.shortcut, this.ctrl_count, function() {
self.viewmanager.active_view.controller.do_add_record();
});
}
},
destroy: function() {
$.ctrl_unbind(this.ctrl_count);
this._super.apply(this, arguments);
},
});
});
It may require more extensions but this is the first draft
define the shorcut in the context like context="{'shortcut': 'I'}"
There was no solution using the normal events of the Listview?
E.g.:
keyup_NUMPAD_ADD: function (e) {
this.do_add_record();
}
Hi Sridhar,
Did you get the solution? I also need the same thing fo my module.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Jul 24
|
401 | ||
|
1
Jul 23
|
3223 | ||
|
0
Mar 24
|
1984 | ||
|
1
Sep 22
|
4952 | ||
|
1
Mar 22
|
3820 |