This question has been flagged
4769 Views

How to extend or inherit a javascript object from a custom module, I want extend the object instance.web.DateTimeWidget from addons/web/static/src/js/view_form.js to set the yearRange in the picker method.

The original file:

instance.web.DateTimeWidget = instance.web.Widget.extend({

...

this.picker({
            onClose: this.on_picker_select,
            onSelect: this.on_picker_select,
            changeMonth: true,
            changeYear: true,
            showWeek: true,
            showButtonPanel: true,
            firstDay: Date.CultureInfo.firstDayOfWeek
        });

...

});

I want this:

instance.web.DateTimeWidget = instance.web.Widget.extend({

...

this.picker({
            onClose: this.on_picker_select,
            onSelect: this.on_picker_select,
            changeMonth: true,
            changeYear: true,
            yearRange: 'c-70:c+0',
            showWeek: true,
            showButtonPanel: true,
            firstDay: Date.CultureInfo.firstDayOfWeek
        });

...

});

All this without modifying the file that brings odoo view_form.js.

Thanks.

Avatar
Discard