跳至內容
選單
此問題已被標幟
2 回覆
13784 瀏覽次數

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
3996
1
4月 22
3069
10
12月 24
30855
1
11月 23
9965
0
11月 23
2047