simahawk
simahawk

Reputation: 2431

how to extend basic field widget on the web client

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

Upvotes: 1

Views: 1202

Answers (1)

Guewen Baconnier
Guewen Baconnier

Reputation: 36

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

Upvotes: 2

Related Questions