问题描述:

I'm trying to customize the basic Field object on the web client. Here's my code:

openerp.web_mymodule = function(openerp) {

openerp.web.form.Field = openerp.web.form.Field.extend({

init: function(view, node) {

console.log('mine');

this._super(view, node);

}

});

[...]

}

but is not working. AFAIK this should work as well as the following code (in the same file) is working:

[...]

openerp.web.form.FieldChar = openerp.web.form.FieldChar.extend({

init: function (view, node) {

this._super(view, node);

console.log('mine')

}

});

The only difference I can see is that all the widgets, FieldChar included, are registered in view_form.js whilst Field is not.

Am I missing some "black magic" behind this? tnx

网友答案:

Did you try using include instead of extend?

openerp.web_mymodule = function(openerp) {

    openerp.web.form.Field.include({
        init: function(view, node) {
            console.log('mine');
            this._super(view, node);
        }
    });
    [...]
}

xmo wrote an explanation here: openerp web client 6.1: how to override base javascript functions

相关阅读:
Top