I'm working on a custom module for POS. When i set a current screen, i can't back on the previous. Here is the error i got:
Software Error (user interface)
Uncaught TypeError: this.current_screen.close is not a function
http://localhost/web/js/web.assets_backend/5b337eb:4502
This is the code i wrote
function pos_ordonnance(instance, module){
var QWeb = instance.web.qweb;
module.PosWidget.include({
build_widgets: function(){
var self = this;
this._super();
// -------- Ordonnance screen and his selector ---------
this.ordonnance_screen = new module.OrdonnanceListWidget(this,{});
this.ordonnance_screen.appendTo(this.$('.screens'));
this.screen_selector.add_screen('ordonnances',this.ordonnance_screen);
});
module.OrdonnanceButtonWidget = module.PosBaseWidget.extend({
template: 'OrdonnanceButtonWidget',
init: function(parent, options){
this._super(parent);
}
});
module.OrdonnanceListWidget = module.PosBaseWidget.extend({
template:'OrdonnanceListWidget',
init: function(parent, options) {
this._super(parent);
},
renderElement: function() {
var self = this;
this._super();
self.afficherOrdonnance()
self.get_ordonnances()
},
afficherOrdonnance: function(){
var button = $(QWeb.render('OrdonnanceButtonWidget'));
button.appendTo($('.control-buttons'));
$('.control-buttons').removeClass('oe_hidden');
$('.control-buttons').addClass('mypad');
button.click(function(){
$(QWeb.render('OrdonnanceListWidget'));
$('.ordonnance-list-container').removeClass('oe_hidden');
self.pos_widget.screen_selector.set_current_screen('ordonnances');
})
},
get_ordonnances: function(){
var self = this;
var ordonnance_list = [];
var loaded = new instance.web.Model("oeh.medical.prescription");
loaded.call("get_ordonnances_to_pos", {context: new instance.web.CompoundContext()})
.then(function(ordonnance){
for(var i = 0, len = ordonnance['result'].length; i < len; i++){
var content = $('.ordo-content-tbody').html();
var ordo_prescription = ordonnance['result'][i]['name']
var ordo_patient = ordonnance['result'][i]['patient'][1]
var ordo_date = ordonnance['result'][i]['date']
var ordo_doctor = ordonnance['result'][i]['doctor'][1]
var new_prescription = '<td class=ordo-prescription\'' + ordo_prescription + '\'>' + ordo_prescription + '</td>\n';
var new_patient = '<td class=ordo-patient\'' + ordo_patient + '\'>' + ordo_patient + '</td>\n';
var new_date = '<td class=ordo-date\'' + ordo_date + '\'>' + ordo_date + '</td>\n';
var new_doctor = '<td class=ordo-doctor\'' + ordo_doctor + '\'>' + ordo_doctor + '</td>\n';
var new_tr_prescription = '<tr class=ordo prescription-tr\'' + ordo_prescription + '\'>' + new_prescription + new_patient + new_date + new_doctor + '</tr>\n';
$('.ordo-content-tbody').html(content + new_tr_prescription);
}
});
}
});
}
(function(){
var _super = window.openerp.point_of_sale;
window.openerp.point_of_sale = function(instance){
_super(instance);
var module = instance.point_of_sale;
pos_ordonnance(instance, module);
}
})();