From 4f51882863a12539265134a97dc5d2a2913a013b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Mon, 8 Jul 2013 16:55:22 +0200 Subject: [PATCH] [IMP] point_of_sale: reworked the way the weighting debug mode works to make it more robust bzr revid: fva@openerp.com-20130708145522-6r5yedizrg9h6m0r --- addons/point_of_sale/static/src/js/devices.js | 38 +++++++++---------- addons/point_of_sale/static/src/js/screens.js | 2 - addons/point_of_sale/static/src/js/widgets.js | 1 + 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/addons/point_of_sale/static/src/js/devices.js b/addons/point_of_sale/static/src/js/devices.js index fe16b2d4bbf..835b7fe7b5a 100644 --- a/addons/point_of_sale/static/src/js/devices.js +++ b/addons/point_of_sale/static/src/js/devices.js @@ -12,6 +12,8 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal this.weight = 0; this.weighting = false; + this.debug_weight = 0; + this.use_debug_weight = false; this.paying = false; this.default_payment_status = { @@ -92,38 +94,36 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal // and a weighting_end() weighting_read_kg: function(){ var self = this; - if(this.bypass_proxy){ - return this.weight; - }else{ - this.message('weighting_read_kg',{}) - .done(function(weight){ - if(self.weighting && !self.bypass_proxy){ + this.message('weighting_read_kg',{}) + .done(function(weight){ + if(self.weighting){ + if(self.use_debug_weight){ + self.weight = self.debug_weight; + }else{ self.weight = weight; } - }); - return this.weight; - } + } + }); + return this.weight; }, // sets a custom weight, ignoring the proxy returned value. debug_set_weight: function(kg){ - this.bypass_proxy = true; - this.weight = kg; + this.use_debug_weight = true; + this.debug_weight = kg; }, // resets the custom weight and re-enable listening to the proxy for weight values debug_reset_weight: function(){ - this.bypass_proxy = false; - this.weight = 0; + this.use_debug_weight = false; + this.debug_weight = 0; }, // the client has finished weighting products - weighting_end: function(force){ - if(!this.bypass_proxy || force){ - this.weight = 0; - this.weighting = false; - this.message('weighting_end'); - } + weighting_end: function(){ + this.weight = 0; + this.weighting = false; + this.message('weighting_end'); }, // the pos asks the client to pay 'price' units diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index 0747fcd3d35..20253ffd27b 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -459,7 +459,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa icon: '/point_of_sale/static/src/img/icons/png48/go-previous.png', click: function(){ clearInterval(this.intervalID); - self.pos.proxy.weighting_end(); self.pos_widget.screen_selector.set_current_screen(self.previous_screen); } }); @@ -527,7 +526,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa }, order_product: function(){ var weight = this.pos.proxy.weighting_read_kg(); - this.pos.proxy.weighting_end('true'); this.pos.get('selectedOrder').addProduct(this.get_product(),{ quantity:weight }); }, get_product_name: function(){ diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js index 96ccd85134d..24660ab6377 100644 --- a/addons/point_of_sale/static/src/js/widgets.js +++ b/addons/point_of_sale/static/src/js/widgets.js @@ -743,6 +743,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa } }); this.$('.button.reset_weight').click(function(){ + self.$('input.weight').val(''); self.pos.proxy.debug_reset_weight(); }); this.$('.button.custom_ean').click(function(){