summaryrefslogtreecommitdiff
path: root/addons/stock/static/src/js/widgets.js
diff options
context:
space:
mode:
authorCedric Snauwaert <csn@openerp.com>2014-03-28 11:49:06 +0100
committerCedric Snauwaert <csn@openerp.com>2014-03-28 11:49:06 +0100
commit8c7a9fa0ae2eebb4cd9c19d2a1e81b7581eabb84 (patch)
treefe834a2bcfbb169da0956ddbc503041adaf69a38 /addons/stock/static/src/js/widgets.js
parenta7fdd2371f80814c8c8760b509019865262b6c2b (diff)
[FIX]stock_barcode_interface: add button to recompute pack_op when state of move have changed
bzr revid: csn@openerp.com-20140328104906-d8pebnlwlpdf4x10
Diffstat (limited to 'addons/stock/static/src/js/widgets.js')
-rw-r--r--addons/stock/static/src/js/widgets.js43
1 files changed, 33 insertions, 10 deletions
diff --git a/addons/stock/static/src/js/widgets.js b/addons/stock/static/src/js/widgets.js
index 756d3caf841..8bb36bd3e42 100644
--- a/addons/stock/static/src/js/widgets.js
+++ b/addons/stock/static/src/js/widgets.js
@@ -534,7 +534,6 @@ function openerp_picking_widgets(instance){
this.picking = null;
this.pickings = [];
this.packoplines = null;
- this.operations = null;
this.selected_operation = { id: null, picking_id: null};
this.packages = null;
this.barcode_scanner = new module.BarcodeScanner();
@@ -604,20 +603,22 @@ function openerp_picking_widgets(instance){
}
return loaded_picking.then(function(){
- new instance.web.Model('stock.location').call('search',[[['usage','=','internal']]]).then(function(locations_ids){
+ return new instance.web.Model('stock.location').call('search',[[['usage','=','internal']]]).then(function(locations_ids){
return new instance.web.Model('stock.location').call('read',[locations_ids, []]).then(function(locations){
self.locations = locations;
});
});
}).then(function(){
-
- return new instance.web.Model('stock.pack.operation').call('read',[self.picking.pack_operation_ids, [], new instance.web.CompoundContext()]);
- }).then(function(packoplines){
- self.packoplines = packoplines;
-
- return new instance.web.Model('stock.pack.operation').call('read',[self.picking.pack_operation_ids, [], new instance.web.CompoundContext()]);
+ if (self.picking.pack_operation_exist === false){
+ self.picking.recompute_pack_op = false;
+ return new instance.web.Model('stock.picking').call('do_prepare_partial',[[self.picking.id]]);
+ }
+ }).then(function(){
+ return new instance.web.Model('stock.pack.operation').call('search',[[['picking_id','=',self.picking.id]]])
+ }).then(function(pack_op_ids){
+ return new instance.web.Model('stock.pack.operation').call('read',[pack_op_ids, [], new instance.web.CompoundContext()])
}).then(function(operations){
- self.operations = operations;
+ self.packoplines = operations;
var package_ids = [];
for(var i = 0; i < operations.length; i++){
@@ -627,7 +628,7 @@ function openerp_picking_widgets(instance){
}
}
}
- return new instance.web.Model('stock.quant.package').call('read',[package_ids, [], new instance.web.CompoundContext()]);
+ return new instance.web.Model('stock.quant.package').call('read',[package_ids, [], new instance.web.CompoundContext()])
}).then(function(packages){
self.packages = packages;
});
@@ -644,6 +645,7 @@ function openerp_picking_widgets(instance){
this.$('.js_pick_prev').click(function(){ self.picking_prev(); });
this.$('.js_pick_next').click(function(){ self.picking_next(); });
this.$('.js_pick_menu').click(function(){ self.menu(); });
+ this.$('.js_reload_op').click(function(){ self.reload_pack_operation();});
this.hotkey_handler = function(event){
if(event.keyCode === 37 ){ // Left Arrow
@@ -670,6 +672,12 @@ function openerp_picking_widgets(instance){
}else{
self.$('.js_pick_next').removeClass('disabled');
}
+ if (self.picking.recompute_pack_op){
+ self.$('.js_reload_op').removeClass('hidden');
+ }
+ else {
+ self.$('.js_reload_op').addClass('hidden');
+ }
}).fail(function(error) {console.log(error);});
@@ -691,6 +699,13 @@ function openerp_picking_widgets(instance){
self.picking_editor.remove_blink();
self.picking_editor.renderElement();
+ if (self.picking.recompute_pack_op){
+ self.$('.js_reload_op').removeClass('hidden');
+ }
+ else {
+ self.$('.js_reload_op').addClass('hidden');
+ }
+
if( self.picking.id === self.pickings[0]){
self.$('.js_pick_prev').addClass('disabled');
}else{
@@ -886,6 +901,14 @@ function openerp_picking_widgets(instance){
}
},
+ reload_pack_operation: function(){
+ var self = this;
+ new instance.web.Model('stock.picking')
+ .call('do_prepare_partial',[[self.picking.id]])
+ .then(function(){
+ self.refresh_ui(self.picking.id);
+ });
+ },
quit: function(){
this.destroy();
return new instance.web.Model("ir.model.data").get_func("search_read")([['name', '=', 'action_picking_type_form']], ['res_id']).pipe(function(res) {