콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
13811 화면

I want to register onclick event for a button. Please help

odoo.define('test.payment_checkout', require => {
'use strict';

const core = require('web.core');
const Dialog = require('web.Dialog');

const _t = core._t;
console.log('test.payment_checkout');
return {
start: function () {
$('#test').click(function () {
console.log("TEST")
});
},

}
})

The file is loaded because I can see the console.log in browser's console. But the button didn't do anything

아바타
취소
베스트 답변

Hi,

You can try like this example.

odoo.define('test.shop_cart', function (require) {
"use strict";

var rpc = require('web.rpc');

$(document).on('click', '#test_button', function(){

     console.log("test")
 });
});

Regards

아바타
취소

Can you post the full code, I try to call JavaScript from button click on a form but didn't get any result.

작성자 베스트 답변

I figured it out

odoo.define('test.shop_cart', function (require) {
"use strict";

var rpc = require('web.rpc');

$(document).on('click', '#test_button', function () {

console.log("test")
return rpc.query({
model: 'my_module.test',
method: 'get_sale_order',
args: [""],
})
.then(function (result) {
console.log(result)
});
});
});

def get_sale_order(self):
return "TEST"


아바타
취소
관련 게시물 답글 화면 활동
2
4월 22
4011
1
4월 22
3073
10
12월 24
30911
1
11월 23
9979
0
11월 23
2063