简体   繁体   中英

Odoo 8 - How to make the enter key work as tab key in form view?

I can't figure out how to make enter key work instead of tab key to navigate between fields in form view in odoo v8,i have followed this post already https://www.odoo.com/forum/help-1/question/how-to-make-the-enter-key-work-as-tab-key-1310

But the code mentioned in this post works only for tree editable view .

This is reference code in JS for your needs to focus next using enter.

Modify it as you wanted it.

window.onkeypress = function(e) {
    if (e.which == 13) {
        e.preventDefault();
        var inputs = document.getElementsByClassName('input');
        for (var k = 0; k < inputs.length; k++) {
        if (document.activeElement.id == inputs[k].id && k+1 < inputs.length ) {
            inputs[k+1].focus();
            break;   
        }
    }

I solved it !

Here is the link and of course credits are mentioned in the repository

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM