Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
5677 Lượt xem

I would like to listen for the onChange event of a field in Odoo 16 using JavaScript.

I have attempted several code snippets, but unfortunately, none of them proved successful.

As I am unable to post links here please visit the following link for full details.


https://stackoverflow.com/questions/76697815/how-can-i-listen-to-the-onfieldchange-event-in-odoo-16-using-javascript


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

You can use the "t-on-change" attribute to call a function when values change in the field in Odoo 16.

In xml you can give like,


<input type="file" t-on-change="functionToBeCalled"/>


and in JS you can write the function definition.


functionToBeCalled(ev) {
        //What action to perform.
}


Hope it works

Ảnh đại diện
Huỷ bỏ
Tác giả

Thank you but I want to do it in Form view not in Qweb.

Câu trả lời hay nhất

Hi


odoo.define("module_name.value_group_by", function (require) {
"use strict";
var publicWidget = require('web.public.widget');
var registry = require("@web/core/registry")
var ajax = require('web.ajax');
var core = require('web.core');
var QWeb = core.qweb;
var Template = publicWidget.Widget.extend({
selector: '.value_group_by',
events : {
'change #group_select_value' : '_onChangeValue'
},
// This is for getting group value
_onChangeValue: function(){
let self = this
var
search_value = self.$el.find("#group_select_value").val();

}
})
publicWidget.registry.value_group_by = Template;
return Template
})


Regards

Ảnh đại diện
Huỷ bỏ
Tác giả

What is value_group_by and group_select_value?

value group_select_value is the class name of the field,

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 24
2102
0
thg 1 24
1674
1
thg 9 23
3099
2
thg 4 23
5268
2
thg 1 23
7755