Odoo Help

0

Add an item button Shortcut in Odoo 9

By
sridhar
on 11/3/15, 5:24 AM 756 views

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.

1

Axel Mendoza

--Axel Mendoza--
11073
| 7 7 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 11/3/15, 6:49 AM

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'}"

Axel Mendoza
on 11/3/15, 6:53 AM
0
Shahid M
On 12/26/15, 1:25 PM

Hi Sridhar,

Did you get the solution? I also need the same thing fo my module.

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: 11/3/15, 5:24 AM
Seen: 756 times
Last updated: 12/26/15, 1:25 PM