İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
13511 Görünümler

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

Avatar
Vazgeç
En İyi Yanıt

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

Avatar
Vazgeç

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

Üretici En İyi Yanıt

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"


Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
2
Nis 22
3756
1
Nis 22
2889
10
Ara 24
30366
1
Kas 23
9702
0
Kas 23
1847