diff --git a/addons/point_of_sale/static/src/css/pos.css b/addons/point_of_sale/static/src/css/pos.css index 2ff5fbf9dd3..d93f29f740f 100644 --- a/addons/point_of_sale/static/src/css/pos.css +++ b/addons/point_of_sale/static/src/css/pos.css @@ -487,3 +487,7 @@ background-color: #D92A2A; } +.point-of-sale .oe_pos-close-warning { + height: 500px; +} + diff --git a/addons/point_of_sale/static/src/js/pos.js b/addons/point_of_sale/static/src/js/pos.js index 423399b9c07..21ff6de3ec2 100644 --- a/addons/point_of_sale/static/src/js/pos.js +++ b/addons/point_of_sale/static/src/js/pos.js @@ -25,6 +25,7 @@ openerp.point_of_sale = function(db) { return QWeb.render(template, ctx); }; }; + var _t = db.web._t; /* Local store access. Read once from localStorage upon construction and persist on every change. @@ -1211,12 +1212,36 @@ openerp.point_of_sale = function(db) { }); }, changed_pending_operations: function () { - var operations = pos.get('pending_operations'); - var number = operations.length; - this.synch_notification.on_change_nbr_pending(number); + this.synch_notification.on_change_nbr_pending(pos.get('pending_operations').length); }, try_close: function() { - this.close(); + pos.flush().then(_.bind(function() { + var close = _.bind(this.close, this); + if (pos.get('pending_operations').length > 0) { + var confirm = false; + $(QWeb.render('pos-close-warning')).dialog({ + resizable: false, + height:160, + modal: true, + title: "Warning", + buttons: { + "Yes": function() { + confirm = true; + $( this ).dialog( "close" ); + }, + "No": function() { + $( this ).dialog( "close" ); + } + }, + close: function() { + if (confirm) + close(); + } + }); + } else { + close(); + } + }, this)); }, close: function() { this.stop(); diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index 61a5af2a17b..8b82bafd648 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -130,6 +130,9 @@ + + There are pending operations that could not be saved into the database, are you sure you want to exit? +