简体   繁体   中英

Override JS function in odoo 8

I need to override a function render_value of widget instance.web.form.FieldSelection . 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);

use this in method from starting.

Hope this will help you !!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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