[FIX] point_of_sale: the electronic scale is now always deactivated
authorFrédéric van der Essen <fva@openerp.com>
Thu, 22 Nov 2012 13:22:48 +0000 (14:22 +0100)
committerFrédéric van der Essen <fva@openerp.com>
Thu, 22 Nov 2012 13:22:48 +0000 (14:22 +0100)
bzr revid: fva@openerp.com-20121122132248-qfxbs04z9tunoi8l

addons/point_of_sale/static/src/js/devices.js
addons/point_of_sale/static/src/js/screens.js
addons/point_of_sale/static/src/js/widgets.js
addons/point_of_sale/static/src/xml/pos.xml

index 98f0dcf..782aac8 100644 (file)
@@ -79,10 +79,11 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
         //the client is starting to weight
         weighting_start: function(){
             if(!this.weighting){
-                this.weight = 0;
                 this.weighting = true;
-                this.bypass_proxy = false;
-                return this.message('weighting_start');
+                if(!this.bypass_proxy){
+                    this.weight = 0;
+                    return this.message('weighting_start');
+                }
             }
         },
 
@@ -104,18 +105,25 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
             }
         },
 
-        // sets a custom weight, ignoring the proxy returned value until the next weighting_end 
+        // sets a custom weight, ignoring the proxy returned value. 
         debug_set_weight: function(kg){
             this.bypass_proxy = true;
             this.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;
+        },
+
         // the client has finished weighting products
         weighting_end: function(){
-            this.weight = 0;
-            this.weighting = false;
-            this.bypass_proxy = false;
-            return this.message('weighting_end');
+            if(!this.bypass_proxy){
+                this.weight = 0;
+                this.weighting = false;
+                this.message('weighting_end');
+            }
         },
 
         // the pos asks the client to pay 'price' units
index b783b17..1abb024 100644 (file)
@@ -467,6 +467,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
         close: function(){
             this._super();
             clearInterval(this.intervalID);
+            this.pos.proxy.weighting_end();
         },
     });
 
index c983b87..0d7a6ca 100644 (file)
@@ -712,6 +712,9 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
                     self.pos.proxy.debug_set_weight(kg);
                 }
             });
+            this.$('.button.reset_weight').click(function(){
+                self.pos.proxy.debug_reset_weight();
+            });
             this.$('.button.custom_ean').click(function(){
                 var ean = self.pos.barcode_reader.sanitize_ean(self.$('input.ean').val() || '0');
                 self.$('input.ean').val(ean);
index e43c0d3..368188c 100644 (file)
                 <ul>
                     <li><input type="text" class="weight"></input></li>
                     <li class="button set_weight">Set Weight</li>
+                    <li class="button reset_weight">Reset</li>
                 </ul>
 
                 <p class="category">Barcode Scanner</p>