Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
178 views
in Technique[技术] by (71.8m points)

javascript - Odoo13: JS within a pop up in account module

enter image description here

I have this cash control pop up. I wanted to click on the table row then insert the value from the number pad. Is there any way I can do that?

I'm putting this script directly in xml. Currently, I need to click the number pad before clicking on the row. Is there any way I can modify it to allow the desire behavior?

if (document.querySelectorAll("input.o_input.o_field_integer")[0] ){
        if (document.getElementsByClassName('use-keyboard-input')[0]){
            document.querySelectorAll("input.o_input.o_field_integer")[0].value = document.getElementsByClassName('use-keyboard-input')[0].value;
            document.querySelectorAll("input.o_input.o_field_integer")[0].dispatchEvent(new Event('change', { 'bubbles': true }));
        }
    }
}, 500)
document.getElementById('cash-control-backspace').onclick = function(event){
    document.getElementsByClassName('use-keyboard-input')[0].value = document.getElementsByClassName('use-keyboard-input')[0].value.slice(0, -1);
}
document.getElementById('cash-control-C').onclick = function(event){
    document.getElementsByClassName('use-keyboard-input')[0].value = '';
}
function returnVal(numStr){
    document.getElementById('cash-control-'+numStr).onclick = function(event){
        document.getElementsByClassName('use-keyboard-input')[0].value = document.getElementsByClassName('use-keyboard-input')[0].value + numStr;                                    
    }
}
returnVal('1')
returnVal('2')
returnVal('3')
returnVal('4')
returnVal('5')
returnVal('6')
returnVal('7')
returnVal('8')
returnVal('9')
returnVal('0')

Any other solution using backbone.js/ jquery/ vanilla js is welcome


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...