diff --git a/addons/stock/static/src/js/widgets.js b/addons/stock/static/src/js/widgets.js index 95c9117889c..5c81d9fae09 100644 --- a/addons/stock/static/src/js/widgets.js +++ b/addons/stock/static/src/js/widgets.js @@ -124,6 +124,7 @@ function openerp_picking_widgets(instance){ this.connect_barcode_scanner(); this.$('.js_pick_quit').click(function(){ self.quit(); }); + this.$('.js_pick_pack').click(function(){ self.pack(); }); $.when(this.loaded).done(function(){ self.picking_editor = new module.PickingEditorWidget(self); @@ -194,6 +195,31 @@ function openerp_picking_widgets(instance){ console.log('Updated the UI'); }); }, + pack: function(){ + var self = this; + console.log('Pack'); + new instance.web.Model('stock.picking').call('action_pack',[[self.picking.id]]) + .then(function(){ + instance.session.user_context.current_package_id = false; + self.current_package_id = instance.session.user_context.current_package_id; + console.log('Context Reset'); + + return new instance.web.Model('stock.pack.operation').call('read',[self.picking.pack_operation_ids, []]) + }).then(function(operations){ + console.log('New Operations: ',operations); + self.operations = operations; + + return new instance.web.Model('stock.quant.package').call('read',[self.picking.package_ids, []]); + }).then(function(packages){ + console.log('New Packages: ',packages); + self.packages = packages; + + self.picking_editor.renderElement(); + self.package_editor.renderElement(); + self.package_selector.renderElement(); + console.log('Updated the UI'); + }); + }, connect_barcode_scanner: function(){ var self =this; var code = [];