0
votes

In stock module the Barcode Scanner page is handled by widget.js and picking.xml through qweb.

I need to override the behaviour in order to add functionalities. So far I've been able to override the xml:

<templates id="template" xml:space="preserve">
 <t t-extend="PickingEditorWidget">
     <t t-jquery="#js_packconf_select" t-operation="after">
         <p>Hello World!</p>
     </t>
 </t>
</templates>

but about the js part I'm stuck. I need to override the behaviour of some functions inside PickingEditorWidget but in widget.js it is first contained inside the object openerp.stock and then the whole openerp.stock is overwritten with a function:

openerp.stock = function(openerp) {
  openerp.stock = openerp.stock || {};
  openerp_picking_widgets(openerp);
}

I've seen this kind of code is in every module, then, how could I change how (for example) this function works without have to rewritten the whole stock/widget.js with my small changes?

this.$('.js_pack_configure').click(function(){
  ....
})

I am not JS expert and I couldn't figure it out...

EDIT:

I put in my module's manifest the stock module in dependances, now I see the PickingEditorWidget object but still I can't make it work my changes

my code (widget.js) is:

function openerp_picking_widgets_extended(instance){

var module = instance.mrp_extended;

module.PickingEditorWidgetExtended = instance.stock.PickingEditorWidget.include({
    renderElement: function(){
        this.$('.js_pack_configure').click(function(){
            <my code>
        });
        this.$('.js_validate_pack').click(function(){
            <my code>
        });
        this._super();
    },
});

}

openerp.mrp_extended = function(openerp) {
  openerp.mrp_extended = openerp.mrp_extended || {};
  openerp_picking_widgets_extended(openerp);
}
1

1 Answers

0
votes

I fixed my code this way:

....
module.PickingEditorWidgetExtended = instance.stock.PickingEditorWidget.include({
    renderElement: function(){
        this._super();
....