From 0ecceb39832ed3bf0f4c20276f2526f027d64ff9 Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert Date: Fri, 7 Mar 2014 14:25:23 +0100 Subject: [PATCH] [WIP]barcode interface, remove extra columns, rework interface, add functionality to split pack_op and set them processed bzr revid: csn@openerp.com-20140307132523-z0eu9jlvi90baugu --- addons/stock/static/src/js/widgets.js | 56 +++++----- addons/stock/static/src/xml/picking.xml | 132 ++++++------------------ addons/stock/stock.py | 15 +++ addons/stock/stock_view.xml | 4 +- 4 files changed, 79 insertions(+), 128 deletions(-) diff --git a/addons/stock/static/src/js/widgets.js b/addons/stock/static/src/js/widgets.js index 6110e325efd..7e347b4b466 100644 --- a/addons/stock/static/src/js/widgets.js +++ b/addons/stock/static/src/js/widgets.js @@ -54,6 +54,10 @@ function openerp_picking_widgets(instance){ }); } }); + + self.rows.sort(function (a,b) { + return (b.classes === '') - (a.classes === ''); + }); return self.rows; }, @@ -87,10 +91,10 @@ function openerp_picking_widgets(instance){ if (query === '') { this.$('.js_pack_op_line.warning').removeClass('warning'); this.$('.js_loc').removeClass('info'); - this.$('.js_pack_op_line.hidden').removeClass('hidden'); + this.$('.js_pack_op_line.hidden').removeClass('hidden'); } }, - get_current_op_selection: function(){ + get_current_op_selection: function(ignore_container){ //get ids of visible on the screen pack_op_ids = [] if (this.$('.js_pack_op_line.warning:not(.js_pack_op_line.hidden)').length > 0){ @@ -110,7 +114,7 @@ function openerp_picking_widgets(instance){ //get list of element in this.rows where rem > 0 and container is empty list = [] _.each(this.rows, function(row){ - if (row.cols.rem > 0 && row.cols.container === undefined){ + if (row.cols.rem > 0 && (ignore_container || row.cols.container === undefined)){ list.push(row.cols.id); } }); @@ -309,11 +313,11 @@ function openerp_picking_widgets(instance){ break; } } - this.$('.oe_picking_not_found').removeClass('hidden'); + this.$('.js_picking_not_found').removeClass('hidden'); clearTimeout(this.picking_not_found_timeout); this.picking_not_found_timeout = setTimeout(function(){ - self.$('.oe_picking_not_found').addClass('hidden'); + self.$('.js_picking_not_found').addClass('hidden'); },2000); }, @@ -323,19 +327,19 @@ function openerp_picking_widgets(instance){ clearTimeout(this.searchbox_timeout); this.searchbox_timout = setTimeout(function(){ if(query){ - self.$('.oe_picking_not_found').addClass('hidden'); - self.$('.oe_picking_categories').addClass('hidden'); - self.$('.oe_picking_search_results').html( + self.$('.js_picking_not_found').addClass('hidden'); + self.$('.js_picking_categories').addClass('hidden'); + self.$('.js_picking_search_results').html( QWeb.render('PickingSearchResults',{results:self.search_picking(query)}) ); - self.$('.oe_picking_search_results .oe_picking').click(function(){ + self.$('.js_picking_search_results .oe_picking').click(function(){ self.goto_picking($(this).data('id')); }); - self.$('.oe_picking_search_results').removeClass('hidden'); + self.$('.js_picking_search_results').removeClass('hidden'); }else{ - self.$('.oe_title_label').removeClass('hidden'); - self.$('.oe_picking_categories').removeClass('hidden'); - self.$('.oe_picking_search_results').addClass('hidden'); + self.$('.js_title_label').removeClass('hidden'); + self.$('.js_picking_categories').removeClass('hidden'); + self.$('.js_picking_search_results').addClass('hidden'); } },100); }, @@ -467,6 +471,7 @@ function openerp_picking_widgets(instance){ this.$('.js_pick_quit').click(function(){ self.quit(); }); this.$('.js_pick_pack').click(function(){ self.pack(); }); + this.$('.js_pick_drop_down').click(function(){ self.drop_down();}); this.$('.js_pick_done').click(function(){ self.done(); }); this.$('.js_pick_print').click(function(){ self.print_picking(); }); this.$('.js_pick_prev').click(function(){ self.picking_prev(); }); @@ -479,10 +484,6 @@ function openerp_picking_widgets(instance){ self.on_searchbox(''); self.$('.oe_searchbox').val(''); }); - this.$('.js_pack_op_line').click(function(){ - console.log("click line"); - $(this).addClass('warning'); - }); this.hotkey_handler = function(event){ if(event.keyCode === 37 ){ // Left Arrow @@ -497,12 +498,6 @@ function openerp_picking_widgets(instance){ $.when(this.loaded).done(function(){ self.picking_editor = new module.PickingEditorWidget(self); self.picking_editor.replace(self.$('.oe_placeholder_picking_editor')); - - // self.package_editor = new module.PackageEditorWidget(self); - // self.package_editor.replace(self.$('.oe_placeholder_package_editor')); - - // self.package_selector = new module.PackageSelectorWidget(self); - // self.package_selector.replace(self.$('.oe_placeholder_package_selector')); if( self.picking.id === self.pickings[0]){ self.$('.js_pick_prev').addClass('disabled'); @@ -536,8 +531,6 @@ function openerp_picking_widgets(instance){ return this.load(picking_id) .then(function(){ self.picking_editor.renderElement(); - // self.package_editor.renderElement(); - // self.package_selector.renderElement(); if( self.picking.id === self.pickings[0]){ self.$('.js_pick_prev').addClass('disabled'); @@ -597,7 +590,7 @@ function openerp_picking_widgets(instance){ }, pack: function(){ var self = this; - var pack_op_ids = self.picking_editor.get_current_op_selection(); + var pack_op_ids = self.picking_editor.get_current_op_selection(false); if (pack_op_ids.length !== 0){ new instance.web.Model('stock.picking') .call('action_pack',[[[self.picking.id]], pack_op_ids]) @@ -607,6 +600,17 @@ function openerp_picking_widgets(instance){ }); } }, + drop_down: function(){ + var self = this; + var pack_op_ids = self.picking_editor.get_current_op_selection(true); + if (pack_op_ids.length !== 0){ + new instance.web.Model('stock.pack.operation') + .call('action_drop_down', [pack_op_ids]) + .then(function(){ + return self.refresh_ui(self.picking.id); + }); + } + }, done: function(){ var self = this; new instance.web.Model('stock.picking') diff --git a/addons/stock/static/src/xml/picking.xml b/addons/stock/static/src/xml/picking.xml index ad48c70bdb8..65c671641b6 100644 --- a/addons/stock/static/src/xml/picking.xml +++ b/addons/stock/static/src/xml/picking.xml @@ -1,7 +1,7 @@ - +
@@ -54,30 +54,23 @@ - - - - - - - - - + + + + - - - - + + + - - - - @@ -86,61 +79,6 @@ - -
-

-
ProductTotal QtyQty doneSource LocationDestination LocationLotPackContainerScanProductQuantityFromTo
➔ / + : + : + ➔
- - - - - - - - - - - - - - - - - - - -
ProductQtyUoM
-
-
- - -
-

- - - - - - - - - - - - - - - - - -
Package
-
Print
-
Copy
-
Delete
- -
-
-

Search Results

@@ -167,36 +105,28 @@
-
-
-

Pickings

- - -
-
- -
-

- Select the type of picking you want to process. -

-
-
+ +

Select your operation

+ -
+ + + +
Print

- - +
+ + + + +
+
- -
-

diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 1f0803b13d4..82879e88f4c 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -3600,6 +3600,21 @@ class stock_pack_operation(osv.osv): if qty > 0: _create_link_for_product(product_id, qty) + def action_drop_down(self, cr, uid, ids, context=None): + ''' Used by barcode interface to say that pack_operation has been moved from src location + to destination location, if qty_done is less than product_qty than we have to split the + operation in two to process the one with the qty moved + ''' + processed_ids = [] + for pack_op in self.browse(cr, uid, ids, context=None): + op = pack_op.id + if pack_op.qty_done < pack_op.product_qty: + # we split the operation in two + op = self.copy(cr, uid, pack_op.id, {'product_qty': pack_op.qty_done, 'qty_done': pack_op.qty_done}, context=context) + self.write(cr, uid, ids, {'product_qty': pack_op.product_qty - pack_op.qty_done, 'qty_done': 0}, context=context) + processed_ids.append(op) + self.write(cr, uid, processed_ids, {'processed': 'true'}, context=context) + def process_packaging(self, cr, uid, operation, quants, context=None): ''' Process the packaging of a given operation, after the quants have been moved. If there was not enough quants found a quant already has been with the good package information so we don't consider that case in this method''' diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 61002d83f12..ffa3d6d7f54 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -770,7 +770,8 @@ - + + @@ -778,6 +779,7 @@ +