From 91763dbd570f253d2cbd200f17d4dbefa1dff296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Thu, 19 Sep 2013 15:12:28 +0200 Subject: [PATCH] [IMP] point_of_sale: confirmation message on session close when there are unposted orders bzr revid: fva@openerp.com-20130919131228-hhrp3guno8ddt5m2 --- addons/point_of_sale/static/src/js/widgets.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js index cfec71be68d..0768791651b 100644 --- a/addons/point_of_sale/static/src/js/widgets.js +++ b/addons/point_of_sale/static/src/js/widgets.js @@ -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'); },