From a40a15a3b1a68bec90d2da34fdbdd865415e94dd Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Tue, 18 Feb 2014 00:31:55 +0100 Subject: [PATCH] [FIX] stock, barcode scanner GUI: allow to unselect an operation line to avoid setting a scanned EAN as quantity of current operation bzr revid: qdp-launchpad@openerp.com-20140217233155-b5malaa2agr3vere --- addons/stock/static/src/js/widgets.js | 29 ++++++++++++++------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/addons/stock/static/src/js/widgets.js b/addons/stock/static/src/js/widgets.js index bf824a43c3f..da0a87370ab 100644 --- a/addons/stock/static/src/js/widgets.js +++ b/addons/stock/static/src/js/widgets.js @@ -90,9 +90,14 @@ function openerp_picking_widgets(instance){ this._super(); var model = this.getParent(); this.$('.js_pack_op').click(function(){ - self.$('.js_pack_op').removeClass('oe_selected'); - $(this).addClass('oe_selected'); - model.set_selected_operation(parseInt($(this).attr('op-id'))); + if (!this.classList.contains('oe_selected')){ + self.$('.js_pack_op').removeClass('oe_selected'); + $(this).addClass('oe_selected'); + model.set_selected_operation(parseInt($(this).attr('op-id'))); + } else { + $(this).removeClass('oe_selected'); + model.set_selected_operation(null); + }; }); }, }); @@ -628,14 +633,7 @@ function openerp_picking_widgets(instance){ if( this.selected_operation.picking_id === this.picking.id && this.selected_operation.id ){ return this.selected_operation.id; }else{ - this.selected_operation.picking_id = this.picking.id; - var ops = this.get_current_operations(); - if(ops.length === 0){ - this.selected_operation.id = null; - }else{ - this.selected_operation.id = ops[ops.length - 1].id; - } - return this.selected_operation.id; + return null; } }, reset_selected_operation: function(){ @@ -651,16 +649,19 @@ function openerp_picking_widgets(instance){ var self = this; var op = this.get_selected_operation(); if( !op ){ - return; + //TODO typing the ean of a product manually ? + //(scanning the barcode is already handled somewhere else, and i don't know how to differenciate the 2 operations) + // and the result is that if i uncomment the next line, scanning a product counts it twice + //self.scan(quantity); } - if(typeof quantity === 'number' && quantity >= 0){ + else {if(typeof quantity === 'number' && quantity >= 0){ new instance.web.Model('stock.pack.operation') .call('write',[[op],{'product_qty': quantity }]) .then(function(){ self.refresh_ui(self.picking.id); }); - } + }} }, connect_numpad: function(){