简体   繁体   English

覆盖odoo 8中的JS函数

[英]Override JS function in odoo 8

I need to override a function render_value of widget instance.web.form.FieldSelection . 我需要重写小部件instance.web.form.FieldSelection的函数render_value i have tried below code but nothing happened. 我试过下面的代码,但没有任何反应。

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]);
    }
   },

  });
};

this._super.apply(this, arguments); this._super.apply(this,arguments);

use this in method from starting. 从一开始就使用in方法。

Hope this will help you !! 希望这个能对您有所帮助 !!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM