[IMP] point_of_sale: add a debug option to delete all unsent orders
authorFrederic van der Essen <fva@openerp.com / fvdessen+o@gmail.com>
Tue, 22 Jul 2014 13:58:08 +0000 (15:58 +0200)
committerFrederic van der Essen <fva@openerp.com / fvdessen+o@gmail.com>
Tue, 22 Jul 2014 13:58:08 +0000 (15:58 +0200)
addons/point_of_sale/static/src/js/db.js
addons/point_of_sale/static/src/js/widgets.js
addons/point_of_sale/static/src/xml/pos.xml

index 38230fb..08d4f87 100644 (file)
@@ -345,6 +345,9 @@ function openerp_pos_db(instance, module){
             });
             this.save('orders',orders);
         },
+        remove_all_orders: function(){
+            this.save('orders',[]);
+        },
         get_orders: function(){
             return this.load('orders',[]);
         },
index 40c2b6b..50120f9 100644 (file)
@@ -800,6 +800,16 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
             this.$('.button.show_orders').click(function(){
                 self.pos.pos_widget.screen_selector.show_popup('unsent-orders');
             });
+            this.$('.button.delete_orders').click(function(){
+                self.pos.pos_widget.screen_selector.show_popup('confirm',{
+                    message: _t('Delete Unsent Orders ?'),
+                    comment: _t('This operation will permanently destroy all unsent orders from the local storage. You will lose all the data. This operation cannot be undone.'),
+                    confirm: function(){
+                        self.pos.db.remove_all_orders();
+                        self.pos.set({synch: { state:'connected', pending: 0 }});
+                    },
+                });
+            });
             _.each(this.eans, function(ean, name){
                 self.$('.button.'+name).click(function(){
                     self.$('input.ean').val(ean);
index 3f95a34..d596862 100644 (file)
                 <p class="category">Unsent Orders</p>
                 <ul>
                     <li class="button show_orders">Show All Unsent Orders</li>
+                    <li class="button delete_orders">Delete All Unsent Orders</li>
                 </ul>
 
                 <p class="category">Hardware Status</p>