diff --git a/addons/stock/static/src/css/picking.css b/addons/stock/static/src/css/picking.css index 99957135cd8..1d6dbec83a5 100644 --- a/addons/stock/static/src/css/picking.css +++ b/addons/stock/static/src/css/picking.css @@ -177,7 +177,12 @@ border: solid 1px rgba(0, 0, 0, 0.09); cursor: pointer; } -.oe_pick_widget .js_pack_select{ +.oe_pick_widget .oe_expanded{ + text-align: center; + min-width: 32px; +} +.oe_pick_widget .js_pack_select, +.oe_pick_widget .js_pack_op{ cursor: pointer; } diff --git a/addons/stock/static/src/js/widgets.js b/addons/stock/static/src/js/widgets.js index 7f5aadf9085..3b9ed60c7dd 100644 --- a/addons/stock/static/src/js/widgets.js +++ b/addons/stock/static/src/js/widgets.js @@ -21,7 +21,7 @@ function openerp_picking_widgets(instance){ rem: moveline.remaining_qty, uom: moveline.product_uom[1], loc: moveline.location_id[1], - stat: moveline.state + id: moveline.product_id[0], }, classes: (moveline.qty_remaining < 0 ? 'oe_invalid' : '') }); @@ -29,6 +29,15 @@ function openerp_picking_widgets(instance){ return rows; }, + renderElement: function(){ + var self = this; + this._super(); + this.$('.js_pack_scan').click(function(){ + var id = parseInt($(this).attr('op-id')); + console.log('Id:',id); + self.getParent().scan_product_id(id); + }); + }, }); module.PackageEditorWidget = instance.web.Widget.extend({ @@ -49,12 +58,24 @@ function openerp_picking_widgets(instance){ product: op.product_id[1], uom: op.product_uom ? product_uom[1] : '', qty: op.product_qty, - } + }, + classes: 'js_pack_op '+ (op.id === model.get_selected_operation() ? 'oe_selected' : ''), + att_op_id: op.id, }); }); return rows; }, + renderElement: function(){ + var self = this; + 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'))); + }); + }, }); module.PackageSelectorWidget = instance.web.Widget.extend({ @@ -251,6 +272,7 @@ function openerp_picking_widgets(instance){ this.pickings = []; this.movelines = null; this.operations = null; + this.selected_operation = { id: null, picking_id: null}; this.packages = null; this.barcode_scanner = new module.BarcodeScanner(); this.picking_type_id = params.context.active_id || 0; @@ -261,6 +283,8 @@ function openerp_picking_widgets(instance){ }else{ this.loaded = this.load(); } + + window.pickwidget = this; }, // load the picking data from the server. If picking_id is undefined, it will take the first picking @@ -442,11 +466,21 @@ function openerp_picking_widgets(instance){ }); }, - scan: function(ean){ + scan: function(ean){ //scans a barcode, sends it to the server, then reload the ui var self = this; new instance.web.Model('stock.picking') .call('get_barcode_and_return_todo_stuff', [self.picking.id, ean]) .then(function(){ + self.reset_selected_operation(); + return self.refresh_ui(self.picking.id); + }); + }, + scan_product_id: function(product_id){ //performs the same operation as a scan, but with product id instead + var self = this; + new instance.web.Model('stock.picking') + .call('get_product_id_and_return_todo_stuff', [self.picking.id, product_id]) + .then(function(){ + self.reset_selected_operation(); return self.refresh_ui(self.picking.id); }); }, @@ -546,15 +580,38 @@ function openerp_picking_widgets(instance){ } ops.push(op); }); + console.log('Current Operations:',ops); return ops; }, + get_selected_operation: function(){ + 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; + } + }, + reset_selected_operation: function(){ + if(this.selected_operation.picking_id === this.picking.id){ + this.selected_operation.id = null; + } + }, + set_selected_operation: function(id){ + this.selected_operation.picking_id = this.picking.id; + this.selected_operation.id = id; + }, set_operation_quantity: function(quantity){ var self = this; - var ops = this.get_current_operations(); - if( !ops || ops.length === 0){ + var op = this.get_selected_operation(); + if( !op ){ return; } - var op = ops[ops.length-1]; if(quantity === '++'){ quantity = op.product_qty + 1; diff --git a/addons/stock/static/src/xml/picking.xml b/addons/stock/static/src/xml/picking.xml index 6ed8c180a47..4f8496d499d 100644 --- a/addons/stock/static/src/xml/picking.xml +++ b/addons/stock/static/src/xml/picking.xml @@ -59,7 +59,7 @@