【问题标题】:Override JS function in odoo 8在odoo 8中覆盖JS函数
【发布时间】:2017-03-13 11:49:09
【问题描述】:

我需要覆盖小部件instance.web.form.FieldSelection 的函数render_value。我试过下面的代码,但什么也没发生。

openerp.my_ModuleName = function(instance) {

  instance.web.form.FieldSelection.include({
    render_value: function() {

    var values = this.get("values");
    values =  [[false, this.node.attrs.placeholder || 'Select']].concat(values);
    var found = _.find(values, function(el) { return el[0] === this.get("value"); }, this);
    if (! found) {
        found = [this.get("value"), _t('Unknown')];
        values = [found].concat(values);
    }
    if (! this.get("effective_readonly")) {
        this.$().html(QWeb.render("FieldSelectionSelect", {widget: this, values: values}));
        this.$("select").val(JSON.stringify(found[0]));
    } else {
        this.$el.text(found[1]);
    }
   },

  });
};

【问题讨论】:

    标签: javascript openerp odoo-8


    【解决方案1】:

    this._super.apply(this, arguments);

    从一开始就在方法中使用这个。

    希望对你有帮助!!

    【讨论】:

      猜你喜欢
      • 2016-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-18
      相关资源
      最近更新 更多