Hi,
I want to add some features to POS but I'm not familiar to js.
So for PaymentScreenWidget I was able to add some new functions and to change others, like this :
function openerp_vi_pos_print_invoice(instance, module){
var QWeb = instance.web.qweb;
var _t = instance.web._t;
console.log('print_');
console.log(module);
module.PaymentScreenWidget.include({
init: function(parent, options) {
var self = this;
this._super(parent,options);
//console.log('Init!!!!');
},
show: function(){
this._super();
var self = this;
this.add_action_button({
label: _t('Print Inv.'),
name: 'b_invoice',
icon: '/vi_pos/static/src/img/icons/print.png',
click: function(){
self.print_invoice_func({invoice_vi: true, invoice:true});
},
});
this.update_payment_summary();
},
print_invoice_func: function(options) {
var self = this;
options = options || {};
var currentOrder = this.pos.get('selectedOrder');
//console.log(options.invoice_vi && options.invoice);
if (options.invoice_vi && options.invoice) {
self.validate_order({invoice: options.invoice, invoice_vi:options.invoice_vi});
}
},
update_payment_summary: function() {
this._super();
if(this.pos_widget.action_bar){
this.pos_widget.action_bar.set_button_disabled('b_invoice', !this.is_paid());
}
},
});
}
But when I tried to the same to PosModel:
function openerp_vi_pos_models(instance, module){ //module is instance.point_of_sale
var QWeb = instance.web.qweb;
var _t = instance.web._t;
module.PosModel.include({
new_func: function(order){
var self = this;
var invoiced = new $.Deferred();
if(!order.get_client()){
invoiced.reject('error-no-client');
return invoiced;
}
var order_id = this.db.add_order(order.export_as_JSON());
....
....
},
});
}
I get an error Uncaught TypeError: module.PosModel.include is not a function
So I print the variable module through console.log(module); and I notice that "PaymentScreenWidget" it has defined the include function and the "prototype" is Class and in PosModel we don't have the function include and the prototype is Surrogate.
If I don't have the include function how do I add a function to PosModel?
Thanks