1
votes

I followed the documentation at https://www.odoo.com/documentation/9.0/howtos/web.html

But when I tried to make a read write field I got error Cannot read property 'get' of undefined

<t t-if="! widget.get('effective_readonly')">
    <input type="text"></input>
</t>

This code doesn't recognize widget. What identifier should I use inside the template? If there is no built in identifier, where to define the identifier? And how?

1

1 Answers

0
votes

In the init function

local.FieldNewWidget = instance.web.form.AbstractField.extend({
    init: function(parent, options) {
        this._super(parent, options);
        this._super.apply(this, arguments);
        this.set("value", "");
        this.widget = this;
    },

...

And here

    display_field: function() {
        var self = this;
        self.$el.empty();
        self.$el.append(QWeb.render('yourNewTemplate', {widget: self, data: data}));

...

Done