不在编辑模式下Odoo 10时将窗口小部件设置为只读

时间:2018-10-07 22:24:35

标签: javascript odoo-10

我已经创建了一个自定义窗口小部件,但是我不知道如何为该自定义窗口小部件设置只读行为,我尝试使用此代码,但是不起作用。

init: function() {
    var self = this;
    this._super.apply(this, arguments);
    this.set("value", "");

},
start: function() {
    var self = this;
    this.on("change:effective_readonly", this, function() {
        this.display_field();
        this.render_value();
    });
    this.display_field();
    return this._super();
},
display_field: function() {
    var self = this;
    this.$el.html(QWeb.render('SurveyWidget', {widget: this}));
    if (! this.get("effective_readonly")) {
        this.$("input").change(function() {
            self.internal_set_value(self.$("input").val());
        });
    }
},
render_value: function() {
    if (this.get("effective_readonly")) {
        this.$el.text(this.get("value"));
    } else {
        this.$("input").val(this.get("value"));
    }
},

只有在这种状态下,它才会显示一个不可见的小部件,我没有找到有关此的信息。有什么建议或例子吗?谢谢。

0 个答案:

没有答案