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

Hello my Friends;

Would anyone help to know how can i get values of fields in widget javascript.

I have tried this.field_manager.get_field_value but it doesn't work.

Thanks a lot in advance.

Best regards;

Ảnh đại diện
Huỷ bỏ

Please post your code you are working on.

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

Hi, I had a situation to modify the behaviour of many2many_tags widget. So I extended that widget to create a new widget n include my new field. You may refer my js code if its useful:

odoo.define('my_module.extension', function (require) {
"use strict";

var BasicModel = require('web.BasicModel');
var field_registry = require('web.field_registry');
var Notification = require('web.Notification');
var relational_fields = require('web.relational_fields');
var session = require('web.session');
var WebClient = require('web.WebClient');

var FieldMany2ManyTags = relational_fields.FieldMany2ManyTags;

var Many2ManyContactTags = FieldMany2ManyTags.extend({
tag_template: "Many2ManyContactTags",

fieldsToFetch: _.extend({}, FieldMany2ManyTags.prototype.fieldsToFetch, {
//***fetching a new field****
        description: {type: 'text'},

}),



});

field_registry.add('many2manycontacttags', Many2ManyContactTags);

});
Ảnh đại diện
Huỷ bỏ

Hi, may you can explain how to get these values in my js or qweb? Thanks.

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

in your JavaScript file you need a put this function,

init: function (parent, name, record, options) {
this._super(parent, name, record, options);

},

After init method, you got a data this if you put this line

this.record.data[this.field.name];



Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 11 19
7334
1
thg 5 21
15754
1
thg 4 21
4400
0
thg 8 20
3077
1
thg 4 20
3063