[IMP] point_of_sale: confirmation message on session close when there are unposted orders

bzr revid: fva@openerp.com-20130919131228-hhrp3guno8ddt5m2
This commit is contained in:
Frédéric van der Essen 2013-09-19 15:12:28 +02:00
parent 316d079b59
commit 91763dbd57
1 changed files with 12 additions and 1 deletions

View File

@ -668,7 +668,18 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
var self = this;
this._super();
if(this.action){
this.$el.click(function(){ self.action(); });
this.$el.click(function(){
var draft_order = _.find( self.pos.get('orders').models, function(order){
return order.get('orderLines').length !== 0 && order.get('paymentLines').length === 0;
});
if(draft_order){
if (confirm(_t("Pending orders will be lost.\nAre you sure you want to leave this session?"))) {
self.action();
}
}else{
self.action();
}
});
}
},
show: function(){ this.$el.removeClass('oe_hidden'); },