Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
4107 มุมมอง

I added a button in Odoo 17 settings, when I click that button I need to perform a function in js , how?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

In XML file you can define the button. For example:

<button name="button" t-on-click="buttonOnclick" string="Button Name"/>

And in JavaScript file in your module. define your JavaScript function:
async buttonOnclick() {
        console.log('Button Clicked')
    }


Hope it helps

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Is there a way to receive the event in odoo 17?

This is my button on my xml file:

 

And this my my js file with my odoo.define:

odoo.define('sale_order_punch.geoloc', [], async function buttonOnclickPartner() { console.log('Button clicked');

});

This works, but i would like to do something similar to this code of odoo 15 in odoo 17:

odoo.define('sale_order_punch.geoloc', function (require){ 

​"use strict";

​var fromController = require('web.FormController');

​var fromRender = require('web.FormRenderer');

​var FormView = require('web.FormView');

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

​fromController.include({

​_onButtonClicked: function (event) {

​console.log(event.data.record);

​}

​});

});




อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
เม.ย. 24
1748
3
มี.ค. 24
5277
2
เม.ย. 24
4027
0
มี.ค. 24
1118
2
ก.ค. 25
2078