Skip to Content
Menu
This question has been flagged
3 Replies
9094 Views

Iam working in odoo 10, in that i need to modify the default "PackLotLinePopupWidget" so i extend this popup widget in pos module. so for i created a custom module and try to extend the "PackLotLinePopupWidget" from "popups.js" file. But the extended popup is not working in my custom module.

This is the code..

var PackLotLinePopupWidget = PackLotLinePopupWidget.extend({

init: function(parent, options)

{ this._super(parent,options);

var self = this;

this.click_confirm = function(){

alert('testing');

} },

});

Please anyone tell me how to extend this existing popup widget??

Avatar
Discard

Did you find out how to do it? I am trying to do the exact same thing.

Author

Check my answer

Thanks Silviaa, looks great.

Best Answer

I finally found a way. I didn't extend PackLotLinePopupWidget, but I created a new widget and told odoo to use my widget instead. On a module do the following. Remember to load your static files, such as this js document.

/* 
/your_module_name/static/src/js/custom.js
*/

odoo.define('your_module_name.change_packlot_popup', function(require){
"use strict";
var pos = require('point_of_sale.models');
var gui = require('point_of_sale.gui');
var popup = require('point_of_sale.popups');
 
pos.Order.prototype.display_lot_popup = function(){ var order_line = this.get_selected_orderline();

if (order_line){
var pack_lot_lines = order_line.compute_lot_lines();

this.pos.gui.show_popup('your_custom_widget', {
'title': _t('Lot/Serial Number(s) Required'),
'pack_lot_lines': pack_lot_lines,
'order': this 
});
}
};

var YourCustomPopupWidget = popup.extend({
// Just copy PackLotLinePopupWidget contents in here and modify
// any business logic you need. Then remember to register your widget in gui.
});
gui.define_popup({name:'your_custom_widget', YourCustomPopupWidget});
});
Avatar
Discard
Author Best Answer

Use like this :

Extended like this.
var PopupWidget = require('point_of_sale.popups');
    var PackLotLinePopupWidget = PopupWidget.extend({
          template: 'PackLotLinePopupWidget',
         
            click_confirm: function(){
               
            }
     });
     gui.define_popup({name:'packlotline', widget: PackLotLinePopupWidget});
});

Avatar
Discard