I have tried this solustion but couldn't get it working. So situation is there a parent which doesn't have any event defined. I can not make any change in parent. I can make changes only in child modules so I need to have two child modules both adding a different event but both are independent of each other. It means If I install one of child modules its event should work, If both are installed both events should work.
but doesn't seem to work
Parent
module.PaymentScreenWidget = module.ScreenWidget.extend({
//it has no event defined
some code here....
https://github.com/odoo/odoo/blob/8.0/addons/point_of_sale/static/src/js/screens.js#L997
});
Module 1
function pos_discount_cards_widgets(instance, module){ //module is instance.point_of_sale
var QWeb = instance.web.qweb;
var _t = instance.web._t;
module.PaymentScreenWidgetDsicount = module.PaymentScreenWidget.extend({
events: function(){
return _.extend({},module.PaymentScreenWidget.prototype.events,{
"change .discount-card-select": "selectCard"
});
},
selectCard: function(e){
this.pos_widget.order_widget.update_summary();
this.pos_widget.payment_screen.update_payment_summary();
},
});
} //end of code
Module 2
function pos_payment_with_decimal(instance, module){ //module is instance.point_of_sale
var QWeb = instance.web.qweb;
var _t = instance.web._t;
module.PaymentScreenWidgetDecimal = module.PaymentScreenWidget.extend({
events: function(){
return _.extend({},module.PaymentScreenWidget.prototype.events,{
'keyup': 'keyAction',
});
},
keyAction: function(e) {
var selected = $('.selected .paymentline-input').attr('value');
var re = /[,.]/g;
var str = selected.toString();
var subst = '';
var result = str.replace(re, subst);
this.$('.selected .paymentline-input').val((result * 0.01).toFixed(2));
},
});
} //end of code