コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
13772 ビュー

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
3987
1
4月 22
3067
10
12月 24
30830
1
11月 23
9958
0
11月 23
2039