2013-06-26 08:30:39 +00:00
|
|
|
function openerp_picking_widgets(instance){
|
2013-11-13 17:24:48 +00:00
|
|
|
|
2013-06-26 08:30:39 +00:00
|
|
|
var module = instance.stock;
|
2013-11-13 17:24:48 +00:00
|
|
|
var _t = instance.web._t;
|
|
|
|
var QWeb = instance.web.qweb;
|
2013-06-26 08:30:39 +00:00
|
|
|
|
2013-11-18 10:15:50 +00:00
|
|
|
// This widget makes sure that the scaling is disabled on mobile devices.
|
|
|
|
// Widgets that want to display fullscreen on mobile phone need to extend this
|
|
|
|
// widget.
|
|
|
|
|
|
|
|
module.MobileWidget = instance.web.Widget.extend({
|
|
|
|
start: function(){
|
|
|
|
if(!$('#oe-mobilewidget-viewport').length){
|
|
|
|
$('head').append('<meta id="oe-mobilewidget-viewport" name="viewport" content="initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">');
|
|
|
|
}
|
|
|
|
return this._super();
|
|
|
|
},
|
|
|
|
destroy: function(){
|
|
|
|
$('#oe-mobilewidget-viewport').remove();
|
|
|
|
return this._super();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2013-06-26 08:30:39 +00:00
|
|
|
module.PickingEditorWidget = instance.web.Widget.extend({
|
|
|
|
template: 'PickingEditorWidget',
|
2013-06-26 13:11:31 +00:00
|
|
|
init: function(parent,options){
|
|
|
|
this._super(parent,options);
|
2014-03-21 15:34:05 +00:00
|
|
|
var self = this;
|
2014-03-06 13:38:55 +00:00
|
|
|
this.rows = [];
|
2014-03-18 10:40:25 +00:00
|
|
|
this.search_filter = "";
|
2014-03-19 10:07:58 +00:00
|
|
|
jQuery.expr[":"].Contains = jQuery.expr.createPseudo(function(arg) {
|
|
|
|
return function( elem ) {
|
|
|
|
return jQuery(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
|
|
|
|
};
|
|
|
|
});
|
2013-06-26 13:11:31 +00:00
|
|
|
},
|
2014-03-21 15:34:05 +00:00
|
|
|
get_header: function(){
|
|
|
|
return this.getParent().get_header();
|
|
|
|
},
|
2014-03-20 15:40:56 +00:00
|
|
|
get_location: function(){
|
|
|
|
var model = this.getParent();
|
|
|
|
var locations = [];
|
|
|
|
var self = this;
|
|
|
|
_.each(model.locations, function(loc){
|
|
|
|
locations.push({name: loc.complete_name, id: loc.id,});
|
|
|
|
});
|
|
|
|
return locations;
|
|
|
|
},
|
2013-06-26 08:30:39 +00:00
|
|
|
get_rows: function(){
|
2013-06-26 14:14:21 +00:00
|
|
|
var model = this.getParent();
|
2014-03-06 13:38:55 +00:00
|
|
|
this.rows = [];
|
2014-03-04 16:44:46 +00:00
|
|
|
var self = this;
|
2014-03-11 15:55:32 +00:00
|
|
|
var pack_created = [];
|
2014-03-04 09:20:23 +00:00
|
|
|
_.each( model.packoplines, function(packopline){
|
2014-03-06 13:38:55 +00:00
|
|
|
var pack = undefined;
|
2014-03-24 10:46:21 +00:00
|
|
|
var color = "";
|
2014-03-06 13:38:55 +00:00
|
|
|
if (packopline.product_id[1] !== undefined){ pack = packopline.package_id[1];}
|
2014-03-24 10:46:21 +00:00
|
|
|
if (packopline.product_qty == packopline.qty_done){ color = "success "; }
|
|
|
|
if (packopline.product_qty < packopline.qty_done){ color = "danger "; }
|
2014-03-11 15:55:32 +00:00
|
|
|
//also check that we don't have a line already existing for that package
|
2014-03-18 10:40:25 +00:00
|
|
|
if (packopline.result_package_id[1] !== undefined && $.inArray(packopline.result_package_id[0], pack_created) === -1){
|
2014-03-11 15:55:32 +00:00
|
|
|
self.rows.push({
|
|
|
|
cols: { product: packopline.result_package_id[1],
|
2014-03-18 10:40:25 +00:00
|
|
|
qty: '',
|
|
|
|
rem: '',
|
2014-03-11 15:55:32 +00:00
|
|
|
uom: undefined,
|
|
|
|
lot: undefined,
|
|
|
|
pack: undefined,
|
|
|
|
container: packopline.result_package_id[1],
|
|
|
|
container_id: undefined,
|
|
|
|
loc: packopline.location_id[1],
|
|
|
|
dest: packopline.location_dest_id[1],
|
|
|
|
id: packopline.result_package_id[0],
|
|
|
|
product_id: undefined,
|
|
|
|
can_scan: false,
|
2014-03-18 10:40:25 +00:00
|
|
|
head_container: true,
|
|
|
|
processed: packopline.processed,
|
2014-03-11 15:55:32 +00:00
|
|
|
},
|
2014-03-21 15:34:05 +00:00
|
|
|
classes: ('success container_head ') + (packopline.processed === "true" ? 'processed hidden ':''),
|
2014-03-11 15:55:32 +00:00
|
|
|
});
|
2014-03-18 10:40:25 +00:00
|
|
|
pack_created.push(packopline.result_package_id[0]);
|
2014-03-11 15:55:32 +00:00
|
|
|
}
|
2014-03-06 13:38:55 +00:00
|
|
|
self.rows.push({
|
|
|
|
cols: { product: packopline.product_id[1] || packopline.package_id[1],
|
|
|
|
qty: packopline.product_qty,
|
|
|
|
rem: packopline.qty_done,
|
|
|
|
uom: packopline.product_uom_id[1],
|
|
|
|
lot: packopline.lot_id[1],
|
|
|
|
pack: pack,
|
|
|
|
container: packopline.result_package_id[1],
|
2014-03-11 15:55:32 +00:00
|
|
|
container_id: packopline.result_package_id[0],
|
2014-03-06 13:38:55 +00:00
|
|
|
loc: packopline.location_id[1],
|
|
|
|
dest: packopline.location_dest_id[1],
|
|
|
|
id: packopline.id,
|
|
|
|
product_id: packopline.product_id[0],
|
2014-03-11 15:55:32 +00:00
|
|
|
can_scan: packopline.result_package_id[1] === undefined ? true : false,
|
|
|
|
head_container: false,
|
2014-03-18 10:40:25 +00:00
|
|
|
processed: packopline.processed,
|
2014-03-06 13:38:55 +00:00
|
|
|
},
|
2014-03-24 10:46:21 +00:00
|
|
|
classes: color + (packopline.result_package_id[1] !== undefined ? 'in_container_hidden ' : '') + (packopline.processed === "true" ? 'processed hidden ':''),
|
2014-03-06 13:38:55 +00:00
|
|
|
});
|
2013-06-26 14:14:21 +00:00
|
|
|
});
|
2014-03-11 15:55:32 +00:00
|
|
|
//sort element by things to do, then things done, then grouped by packages
|
|
|
|
group_by_container = _.groupBy(self.rows, function(row){
|
|
|
|
return row.cols.container;
|
|
|
|
});
|
|
|
|
var sorted_row = [];
|
2014-03-18 10:40:25 +00:00
|
|
|
if (group_by_container.undefined !== undefined){
|
|
|
|
group_by_container.undefined.sort(function(a,b){return (b.classes === '') - (a.classes === '');});
|
|
|
|
$.each(group_by_container.undefined, function(key, value){
|
|
|
|
sorted_row.push(value);
|
|
|
|
});
|
|
|
|
}
|
2014-03-07 13:25:23 +00:00
|
|
|
|
2014-03-11 15:55:32 +00:00
|
|
|
$.each(group_by_container, function(key, value){
|
2014-03-18 10:40:25 +00:00
|
|
|
if (key !== 'undefined'){
|
|
|
|
$.each(value, function(k,v){
|
|
|
|
sorted_row.push(v);
|
|
|
|
});
|
|
|
|
}
|
2014-03-07 13:25:23 +00:00
|
|
|
});
|
2014-03-11 15:55:32 +00:00
|
|
|
|
|
|
|
return sorted_row;
|
2013-06-26 08:30:39 +00:00
|
|
|
},
|
2013-11-15 12:54:28 +00:00
|
|
|
renderElement: function(){
|
|
|
|
var self = this;
|
|
|
|
this._super();
|
2014-03-21 16:21:32 +00:00
|
|
|
this.check_content_screen();
|
2014-03-21 15:34:05 +00:00
|
|
|
this.$('.js_pick_done').click(function(){ self.getParent().done(); });
|
|
|
|
this.$('.js_pick_print').click(function(){ self.getParent().print_picking(); });
|
|
|
|
this.$('.oe_pick_app_header').text(self.get_header());
|
|
|
|
this.$('.oe_searchbox').keyup(function(event){
|
|
|
|
self.on_searchbox($(this).val());
|
|
|
|
});
|
|
|
|
this.$('.js_pick_pack').click(function(){ self.getParent().pack(); });
|
|
|
|
this.$('.js_drop_down').click(function(){ self.getParent().drop_down();});
|
|
|
|
this.$('.js_clear_search').click(function(){
|
|
|
|
self.on_searchbox('');
|
|
|
|
self.$('.oe_searchbox').val('');
|
|
|
|
});
|
2014-03-24 15:56:28 +00:00
|
|
|
this.$('.oe_searchbox').focus(function(){
|
|
|
|
self.getParent().barcode_scanner.disconnect();
|
|
|
|
});
|
|
|
|
this.$('.oe_searchbox').blur(function(){
|
|
|
|
self.getParent().barcode_scanner.connect(function(ean){
|
|
|
|
self.get_Parent().scan(ean);
|
|
|
|
});
|
|
|
|
})
|
2014-03-18 10:40:25 +00:00
|
|
|
this.$('#js_select').change(function(){
|
2014-03-21 15:34:05 +00:00
|
|
|
var selection = self.$('#js_select option:selected').attr('value');
|
2014-03-18 10:40:25 +00:00
|
|
|
if (selection === "ToDo"){
|
2014-03-18 15:51:43 +00:00
|
|
|
self.getParent().$('.js_pick_pack').removeClass('hidden')
|
|
|
|
self.getParent().$('.js_drop_down').removeClass('hidden')
|
2014-03-18 10:40:25 +00:00
|
|
|
self.$('.js_pack_op_line.processed').addClass('hidden')
|
|
|
|
self.$('.js_pack_op_line:not(.processed)').removeClass('hidden')
|
2014-03-06 13:38:55 +00:00
|
|
|
}
|
|
|
|
else{
|
2014-03-18 15:51:43 +00:00
|
|
|
self.getParent().$('.js_pick_pack').addClass('hidden')
|
|
|
|
self.getParent().$('.js_drop_down').addClass('hidden')
|
2014-03-18 10:40:25 +00:00
|
|
|
self.$('.js_pack_op_line.processed').removeClass('hidden')
|
|
|
|
self.$('.js_pack_op_line:not(.processed)').addClass('hidden')
|
2014-03-06 13:38:55 +00:00
|
|
|
}
|
2014-03-18 10:40:25 +00:00
|
|
|
self.on_searchbox(self.search_filter);
|
|
|
|
});
|
|
|
|
this.$('.js_plus').click(function(){
|
2014-03-21 15:34:05 +00:00
|
|
|
var id = $(this).data('product-id');
|
2014-03-24 10:46:21 +00:00
|
|
|
var op_id = $(this).parents("[data-id]:first").data('id');
|
|
|
|
self.getParent().scan_product_id(id,true,op_id);
|
2014-03-18 10:40:25 +00:00
|
|
|
});
|
|
|
|
this.$('.js_minus').click(function(){
|
2014-03-21 15:34:05 +00:00
|
|
|
var id = $(this).data('product-id');
|
2014-03-24 10:46:21 +00:00
|
|
|
var op_id = $(this).parents("[data-id]:first").data('id');
|
|
|
|
self.getParent().scan_product_id(id,false,op_id);
|
2014-03-06 13:38:55 +00:00
|
|
|
});
|
2014-03-11 15:55:32 +00:00
|
|
|
this.$('.js_unfold').click(function(){
|
2014-03-21 15:34:05 +00:00
|
|
|
var op_id = $(this).parent().data('id');
|
2014-03-18 10:40:25 +00:00
|
|
|
var line = $(this).parent();
|
2014-03-11 15:55:32 +00:00
|
|
|
//select all js_pack_op_line with class in_container_hidden and correct container-id
|
2014-03-21 15:34:05 +00:00
|
|
|
select = self.$('.js_pack_op_line.in_container_hidden[data-container-id='+op_id+']')
|
2014-03-11 15:55:32 +00:00
|
|
|
if (select.length > 0){
|
|
|
|
//we unfold
|
2014-03-18 10:40:25 +00:00
|
|
|
line.addClass('warning');
|
2014-03-11 15:55:32 +00:00
|
|
|
select.removeClass('in_container_hidden');
|
|
|
|
select.addClass('in_container');
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
//we fold
|
2014-03-18 10:40:25 +00:00
|
|
|
line.removeClass('warning');
|
2014-03-21 15:34:05 +00:00
|
|
|
select = self.$('.js_pack_op_line.in_container[data-container-id='+op_id+']')
|
2014-03-11 15:55:32 +00:00
|
|
|
select.removeClass('in_container');
|
|
|
|
select.addClass('in_container_hidden');
|
|
|
|
}
|
|
|
|
});
|
2014-03-18 10:40:25 +00:00
|
|
|
this.$('.js_create_lot').click(function(){
|
2014-03-21 15:34:05 +00:00
|
|
|
var op_id = $(this).parents("[data-id]:first").data('id');
|
2014-03-18 10:40:25 +00:00
|
|
|
self.getParent().create_lot(op_id);
|
|
|
|
});
|
|
|
|
this.$('.js_delete_pack').click(function(){
|
2014-03-21 15:34:05 +00:00
|
|
|
var pack_id = $(this).parents("[data-id]:first").data('id');
|
2014-03-18 10:40:25 +00:00
|
|
|
self.getParent().delete_package_op(pack_id);
|
|
|
|
});
|
|
|
|
this.$('.js_print_pack').click(function(){
|
2014-03-21 15:34:05 +00:00
|
|
|
var pack_id = $(this).parents("[data-id]:first").data('id');
|
|
|
|
// $(this).parents("[data-id]:first").data('id')
|
2014-03-18 10:40:25 +00:00
|
|
|
self.getParent().print_package(pack_id);
|
|
|
|
});
|
|
|
|
this.$('.js_submit_value').submit(function(event){
|
2014-03-21 15:34:05 +00:00
|
|
|
var op_id = $(this).parents("[data-id]:first").data('id');
|
|
|
|
var value = parseInt($("input", this).val());
|
2014-03-18 10:40:25 +00:00
|
|
|
if (value>=0){
|
|
|
|
self.getParent().set_operation_quantity(value, op_id);
|
|
|
|
}
|
2014-03-21 15:34:05 +00:00
|
|
|
$("input", this).val("");
|
2014-03-25 08:08:23 +00:00
|
|
|
return false;
|
2014-03-18 10:40:25 +00:00
|
|
|
});
|
2014-03-24 15:56:28 +00:00
|
|
|
this.$('.js_qty').focus(function(){
|
|
|
|
self.getParent().barcode_scanner.disconnect();
|
|
|
|
});
|
2014-03-18 10:40:25 +00:00
|
|
|
this.$('.js_qty').blur(function(){
|
|
|
|
this.value = "";
|
2014-03-24 15:56:28 +00:00
|
|
|
self.getParent().barcode_scanner.connect(function(ean){
|
|
|
|
self.getParent().scan(ean);
|
|
|
|
});
|
2014-03-20 15:40:56 +00:00
|
|
|
});
|
|
|
|
this.$('.js_change_src').click(function(){
|
2014-03-21 15:34:05 +00:00
|
|
|
var op_id = $(this).parents("[data-id]:first").data('id');//data('op_id');
|
2014-03-20 15:40:56 +00:00
|
|
|
self.$('#js_loc_select').addClass('source');
|
2014-03-21 15:34:05 +00:00
|
|
|
self.$('#js_loc_select').data('op-id',op_id);
|
2014-03-20 15:40:56 +00:00
|
|
|
self.$el.siblings('#js_LocationChooseModal').modal();
|
|
|
|
});
|
|
|
|
this.$('.js_change_dst').click(function(){
|
2014-03-21 15:34:05 +00:00
|
|
|
var op_id = $(this).parents("[data-id]:first").data('id');
|
|
|
|
self.$('#js_loc_select').data('op-id',op_id);
|
|
|
|
self.$el.siblings('#js_LocationChooseModal').modal();
|
|
|
|
});
|
|
|
|
this.$('.js_pack_change_dst').click(function(){
|
|
|
|
var op_id = $(this).parents("[data-id]:first").data('id');
|
|
|
|
self.$('#js_loc_select').addClass('pack');
|
|
|
|
self.$('#js_loc_select').data('op-id',op_id);
|
2014-03-20 15:40:56 +00:00
|
|
|
self.$el.siblings('#js_LocationChooseModal').modal();
|
|
|
|
});
|
|
|
|
this.$('.js_validate_location').click(function(){
|
|
|
|
//get current selection
|
|
|
|
var select_dom_element = self.$('#js_loc_select');
|
2014-03-21 15:34:05 +00:00
|
|
|
var loc_id = self.$('#js_loc_select option:selected').data('loc-id');
|
2014-03-20 15:40:56 +00:00
|
|
|
var src_dst = false;
|
2014-03-21 15:34:05 +00:00
|
|
|
var op_id = select_dom_element.data('op-id');
|
|
|
|
if (select_dom_element.hasClass('pack')){
|
|
|
|
select_dom_element.removeClass('source');
|
|
|
|
op_ids = [];
|
|
|
|
self.$('.js_pack_op_line[data-container-id='+op_id+']').each(function(){
|
|
|
|
op_ids.push($(this).data('id'));
|
|
|
|
});
|
|
|
|
op_id = op_ids;
|
|
|
|
}
|
|
|
|
else if (select_dom_element.hasClass('source')){
|
2014-03-20 15:40:56 +00:00
|
|
|
src_dst = true;
|
|
|
|
select_dom_element.removeClass('source');
|
|
|
|
}
|
2014-03-21 15:34:05 +00:00
|
|
|
if (loc_id === false){
|
2014-03-20 15:40:56 +00:00
|
|
|
//close window
|
|
|
|
self.$el.siblings('#js_LocationChooseModal').modal('hide');
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
self.$el.siblings('#js_LocationChooseModal').modal('hide');
|
2014-03-21 15:34:05 +00:00
|
|
|
self.getParent().change_location(op_id, parseInt(loc_id), src_dst);
|
2014-03-20 15:40:56 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
});
|
2014-02-11 15:51:57 +00:00
|
|
|
//remove navigtion bar from default openerp GUI
|
|
|
|
$('td.navbar').html('<div></div>');
|
2013-11-15 12:54:28 +00:00
|
|
|
},
|
2014-03-04 16:44:46 +00:00
|
|
|
on_searchbox: function(query){
|
2014-03-06 13:38:55 +00:00
|
|
|
//hide line that has no location matching the query and highlight location that match the query
|
2014-03-18 10:40:25 +00:00
|
|
|
this.search_filter = query;
|
|
|
|
var processed = ".processed";
|
2014-03-21 15:34:05 +00:00
|
|
|
if (this.$('#js_select option:selected').attr('value') == "ToDo"){
|
2014-03-18 10:40:25 +00:00
|
|
|
processed = ":not(.processed)";
|
|
|
|
}
|
2014-03-05 09:59:17 +00:00
|
|
|
if (query !== '') {
|
2014-03-19 10:07:58 +00:00
|
|
|
this.$('.js_loc:not(.js_loc:Contains('+query+'))').removeClass('info');
|
|
|
|
this.$('.js_loc:Contains('+query+')').addClass('info');
|
|
|
|
this.$('.js_pack_op_line'+processed+':not(.js_pack_op_line:has(.js_loc:Contains('+query+')))').addClass('hidden');
|
|
|
|
this.$('.js_pack_op_line'+processed+':has(.js_loc:Contains('+query+'))').removeClass('hidden');
|
2014-03-05 09:59:17 +00:00
|
|
|
}
|
2014-03-06 13:38:55 +00:00
|
|
|
//if no query specified, then show everything
|
2014-03-05 09:59:17 +00:00
|
|
|
if (query === '') {
|
2014-03-06 13:38:55 +00:00
|
|
|
this.$('.js_loc').removeClass('info');
|
2014-03-18 10:40:25 +00:00
|
|
|
this.$('.js_pack_op_line'+processed+'.hidden').removeClass('hidden');
|
2014-03-05 09:59:17 +00:00
|
|
|
}
|
2014-03-21 16:21:32 +00:00
|
|
|
this.check_content_screen();
|
|
|
|
},
|
|
|
|
check_content_screen: function(){
|
|
|
|
//get all visible element and if none has positive qty, disable put in pack and process button
|
|
|
|
var self = this;
|
|
|
|
var qties = this.$('.js_pack_op_line:not(.processed):not(.hidden) .js_qty').map(function(){return $(this).attr('placeholder')});
|
2014-03-24 08:34:01 +00:00
|
|
|
var container = this.$('.js_pack_op_line.container_head:not(.processed):not(.hidden)')
|
2014-03-21 16:21:32 +00:00
|
|
|
var disabled = true;
|
|
|
|
$.each(qties,function(index, value){
|
|
|
|
if (parseInt(value)>0){
|
|
|
|
disabled = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (disabled){
|
2014-03-24 08:34:01 +00:00
|
|
|
if (container.length===0){
|
|
|
|
self.$('.js_drop_down').addClass('disabled');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
self.$('.js_drop_down').removeClass('disabled');
|
|
|
|
}
|
2014-03-21 16:21:32 +00:00
|
|
|
self.$('.js_pick_pack').addClass('disabled');
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
self.$('.js_drop_down').removeClass('disabled');
|
|
|
|
self.$('.js_pick_pack').removeClass('disabled');
|
|
|
|
}
|
2013-06-26 08:30:39 +00:00
|
|
|
},
|
2014-03-07 13:25:23 +00:00
|
|
|
get_current_op_selection: function(ignore_container){
|
2014-03-06 13:38:55 +00:00
|
|
|
//get ids of visible on the screen
|
|
|
|
pack_op_ids = []
|
2014-03-18 10:40:25 +00:00
|
|
|
this.$('.js_pack_op_line:not(.processed):not(.js_pack_op_line.hidden):not(.container_head)').each(function(){
|
2014-03-21 15:34:05 +00:00
|
|
|
cur_id = $(this).data('id');
|
2014-03-18 10:40:25 +00:00
|
|
|
pack_op_ids.push(parseInt(cur_id));
|
|
|
|
});
|
|
|
|
//get list of element in this.rows where rem > 0 and container is empty is specified
|
2014-03-06 13:38:55 +00:00
|
|
|
list = []
|
|
|
|
_.each(this.rows, function(row){
|
2014-03-07 13:25:23 +00:00
|
|
|
if (row.cols.rem > 0 && (ignore_container || row.cols.container === undefined)){
|
2014-03-06 13:38:55 +00:00
|
|
|
list.push(row.cols.id);
|
|
|
|
}
|
2013-06-28 09:55:47 +00:00
|
|
|
});
|
2014-03-06 13:38:55 +00:00
|
|
|
//return only those visible with rem qty > 0 and container empty
|
|
|
|
return _.intersection(pack_op_ids, list);
|
2014-03-10 16:57:07 +00:00
|
|
|
},
|
2014-03-19 10:07:58 +00:00
|
|
|
remove_blink: function(){
|
|
|
|
this.$('.js_pack_op_line.blink_me').removeClass('blink_me');
|
|
|
|
},
|
|
|
|
blink: function(op_id){
|
|
|
|
this.$('.js_pack_op_line[data-id="'+op_id+'"]').addClass('blink_me');
|
|
|
|
},
|
2014-03-21 15:34:05 +00:00
|
|
|
check_done: function(){
|
|
|
|
var model = this.getParent();
|
|
|
|
var self = this;
|
|
|
|
var done = true;
|
|
|
|
_.each( model.packoplines, function(packopline){
|
|
|
|
if (packopline.processed === "false"){
|
|
|
|
done = false;
|
|
|
|
return done;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return done;
|
2014-03-24 10:46:21 +00:00
|
|
|
},
|
|
|
|
get_visible_ids: function(){
|
|
|
|
var self = this;
|
|
|
|
var visible_op_ids = []
|
|
|
|
var op_ids = this.$('.js_pack_op_line:not(.processed):not(.hidden):not(.container_head):not(.in_container):not(.in_container_hidden)').map(function(){
|
|
|
|
return $(this).data('id');
|
|
|
|
});
|
|
|
|
$.each(op_ids, function(key, op_id){
|
|
|
|
visible_op_ids.push(parseInt(op_id));
|
|
|
|
});
|
|
|
|
return visible_op_ids;
|
|
|
|
},
|
2013-06-26 08:30:39 +00:00
|
|
|
});
|
|
|
|
|
2013-11-18 10:15:50 +00:00
|
|
|
module.PickingMenuWidget = module.MobileWidget.extend({
|
2013-10-03 09:49:04 +00:00
|
|
|
template: 'PickingMenuWidget',
|
|
|
|
init: function(parent, params){
|
|
|
|
this._super(parent,params);
|
|
|
|
var self = this;
|
2014-03-24 15:56:28 +00:00
|
|
|
$(window).bind('hashchange', function(){
|
|
|
|
var states = $.bbq.getState();
|
|
|
|
if (states.action === "stock.ui"){
|
|
|
|
self.do_action({
|
|
|
|
type: 'ir.actions.client',
|
|
|
|
tag: 'stock.ui',
|
|
|
|
target: 'current',
|
|
|
|
},{
|
|
|
|
clear_breadcrumbs: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2013-10-03 09:49:04 +00:00
|
|
|
this.picking_types = [];
|
|
|
|
this.loaded = this.load();
|
|
|
|
this.scanning_type = 0;
|
|
|
|
this.barcode_scanner = new module.BarcodeScanner();
|
|
|
|
this.pickings_by_type = {};
|
2013-11-13 17:24:48 +00:00
|
|
|
this.pickings_by_id = {};
|
|
|
|
this.picking_search_string = "";
|
2013-10-03 09:49:04 +00:00
|
|
|
},
|
|
|
|
load: function(){
|
|
|
|
var self = this;
|
|
|
|
return new instance.web.Model('stock.picking.type').get_func('search_read')([],[])
|
|
|
|
.then(function(types){
|
|
|
|
self.picking_types = types;
|
|
|
|
for(var i = 0; i < types.length; i++){
|
|
|
|
self.pickings_by_type[types[i].id] = [];
|
|
|
|
}
|
|
|
|
self.pickings_by_type[0] = [];
|
|
|
|
|
2014-02-11 15:51:57 +00:00
|
|
|
return new instance.web.Model('stock.picking').call('search_read',[ [['state','in', ['assigned', 'partially_available']]], [] ], {context: new instance.web.CompoundContext()});
|
2013-10-03 09:49:04 +00:00
|
|
|
|
|
|
|
}).then(function(pickings){
|
|
|
|
self.pickings = pickings;
|
|
|
|
for(var i = 0; i < pickings.length; i++){
|
|
|
|
var picking = pickings[i];
|
|
|
|
self.pickings_by_type[picking.picking_type_id[0]].push(picking);
|
2013-11-13 17:24:48 +00:00
|
|
|
self.pickings_by_id[picking.id] = picking;
|
|
|
|
self.picking_search_string += '' + picking.id + ':' + picking.name.toUpperCase() + '\n'
|
2013-10-03 09:49:04 +00:00
|
|
|
}
|
2013-11-13 17:24:48 +00:00
|
|
|
|
2013-10-03 09:49:04 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
renderElement: function(){
|
|
|
|
this._super();
|
|
|
|
var self = this;
|
|
|
|
this.$('.js_pick_quit').click(function(){ self.quit(); });
|
|
|
|
this.$('.js_pick_scan').click(function(){ self.scan_picking($(this).data('id')); });
|
2013-11-13 17:24:48 +00:00
|
|
|
this.$('.js_pick_last').click(function(){ self.goto_last_picking_of_type($(this).data('id')); });
|
2014-02-26 16:10:03 +00:00
|
|
|
this.$('.oe_searchbox').keyup(function(event){
|
2013-11-13 17:24:48 +00:00
|
|
|
self.on_searchbox($(this).val());
|
|
|
|
});
|
2014-02-11 15:51:57 +00:00
|
|
|
//remove navigtion bar from default openerp GUI
|
|
|
|
$('td.navbar').html('<div></div>');
|
2013-10-03 09:49:04 +00:00
|
|
|
},
|
|
|
|
start: function(){
|
2013-11-18 10:15:50 +00:00
|
|
|
this._super();
|
2013-10-03 09:49:04 +00:00
|
|
|
var self = this;
|
2014-02-26 16:10:03 +00:00
|
|
|
instance.webclient.set_content_full_screen(true);
|
2013-10-03 09:49:04 +00:00
|
|
|
this.barcode_scanner.connect(function(barcode){
|
|
|
|
self.on_scan(barcode);
|
|
|
|
});
|
|
|
|
this.loaded.then(function(){
|
|
|
|
self.renderElement();
|
|
|
|
});
|
|
|
|
},
|
2013-11-13 17:24:48 +00:00
|
|
|
goto_picking: function(picking_id){
|
2014-03-24 15:56:28 +00:00
|
|
|
$.bbq.pushState('#action=stock.ui&picking_id='+picking_id);
|
|
|
|
$(window).trigger('hashchange');
|
2013-11-13 17:24:48 +00:00
|
|
|
},
|
|
|
|
goto_last_picking_of_type: function(type_id){
|
2014-03-24 15:56:28 +00:00
|
|
|
$.bbq.pushState('#action=stock.ui&picking_type_id='+type_id);
|
|
|
|
$(window).trigger('hashchange');
|
2013-10-03 09:49:04 +00:00
|
|
|
},
|
2013-11-13 17:24:48 +00:00
|
|
|
search_picking: function(barcode){
|
2014-02-12 10:55:53 +00:00
|
|
|
//TODO don't crash if a not supported char is given
|
2013-11-13 17:24:48 +00:00
|
|
|
var re = RegExp("([0-9]+):.*?"+barcode.toUpperCase(),"gi");
|
|
|
|
var results = [];
|
|
|
|
for(var i = 0; i < 100; i++){
|
|
|
|
r = re.exec(this.picking_search_string);
|
|
|
|
if(r){
|
|
|
|
var picking = this.pickings_by_id[Number(r[1])];
|
|
|
|
if(picking){
|
|
|
|
results.push(picking);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
break;
|
|
|
|
}
|
2013-10-03 09:49:04 +00:00
|
|
|
}
|
2013-11-13 17:24:48 +00:00
|
|
|
return results;
|
2013-10-03 09:49:04 +00:00
|
|
|
},
|
|
|
|
on_scan: function(barcode){
|
2013-11-13 17:24:48 +00:00
|
|
|
var self = this;
|
2013-10-03 09:49:04 +00:00
|
|
|
for(var i = 0, len = this.pickings.length; i < len; i++){
|
|
|
|
var picking = this.pickings[i];
|
2014-02-12 10:55:53 +00:00
|
|
|
if(picking.name.toUpperCase() === $.trim(barcode.toUpperCase())){
|
2013-11-13 17:24:48 +00:00
|
|
|
this.goto_picking(picking.id);
|
|
|
|
break;
|
2013-10-03 09:49:04 +00:00
|
|
|
}
|
|
|
|
}
|
2014-03-07 13:25:23 +00:00
|
|
|
this.$('.js_picking_not_found').removeClass('hidden');
|
2013-11-13 17:24:48 +00:00
|
|
|
|
|
|
|
clearTimeout(this.picking_not_found_timeout);
|
|
|
|
this.picking_not_found_timeout = setTimeout(function(){
|
2014-03-07 13:25:23 +00:00
|
|
|
self.$('.js_picking_not_found').addClass('hidden');
|
2013-11-13 17:24:48 +00:00
|
|
|
},2000);
|
|
|
|
|
|
|
|
},
|
|
|
|
on_searchbox: function(query){
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
clearTimeout(this.searchbox_timeout);
|
|
|
|
this.searchbox_timout = setTimeout(function(){
|
|
|
|
if(query){
|
2014-03-07 13:25:23 +00:00
|
|
|
self.$('.js_picking_not_found').addClass('hidden');
|
|
|
|
self.$('.js_picking_categories').addClass('hidden');
|
|
|
|
self.$('.js_picking_search_results').html(
|
2013-11-13 17:24:48 +00:00
|
|
|
QWeb.render('PickingSearchResults',{results:self.search_picking(query)})
|
|
|
|
);
|
2014-03-07 13:25:23 +00:00
|
|
|
self.$('.js_picking_search_results .oe_picking').click(function(){
|
2013-11-13 17:24:48 +00:00
|
|
|
self.goto_picking($(this).data('id'));
|
|
|
|
});
|
2014-03-07 13:25:23 +00:00
|
|
|
self.$('.js_picking_search_results').removeClass('hidden');
|
2013-11-13 17:24:48 +00:00
|
|
|
}else{
|
2014-03-07 13:25:23 +00:00
|
|
|
self.$('.js_title_label').removeClass('hidden');
|
|
|
|
self.$('.js_picking_categories').removeClass('hidden');
|
|
|
|
self.$('.js_picking_search_results').addClass('hidden');
|
2013-11-13 17:24:48 +00:00
|
|
|
}
|
|
|
|
},100);
|
2013-10-03 09:49:04 +00:00
|
|
|
},
|
|
|
|
quit: function(){
|
2014-02-26 16:10:03 +00:00
|
|
|
return new instance.web.Model("ir.model.data").get_func("search_read")([['name', '=', 'action_picking_type_form']], ['res_id']).pipe(function(res) {
|
|
|
|
window.location = '/web#action=' + res[0]['res_id'];
|
|
|
|
});
|
2013-10-03 09:49:04 +00:00
|
|
|
},
|
|
|
|
destroy: function(){
|
|
|
|
this._super();
|
|
|
|
this.barcode_scanner.disconnect();
|
|
|
|
instance.webclient.set_content_full_screen(false);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
openerp.web.client_actions.add('stock.menu', 'instance.stock.PickingMenuWidget');
|
|
|
|
|
2013-11-18 10:15:50 +00:00
|
|
|
module.PickingMainWidget = module.MobileWidget.extend({
|
2013-06-26 08:30:39 +00:00
|
|
|
template: 'PickingMainWidget',
|
2013-06-26 09:20:29 +00:00
|
|
|
init: function(parent,params){
|
|
|
|
this._super(parent,params);
|
2013-06-26 14:14:21 +00:00
|
|
|
var self = this;
|
2014-03-24 15:56:28 +00:00
|
|
|
$(window).bind('hashchange', function(){
|
|
|
|
var states = $.bbq.getState();
|
|
|
|
if (states.action === "stock.menu"){
|
|
|
|
self.do_action({
|
|
|
|
type: 'ir.actions.client',
|
|
|
|
tag: 'stock.menu',
|
|
|
|
target: 'current',
|
|
|
|
},{
|
|
|
|
clear_breadcrumbs: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
init_hash = $.bbq.getState();
|
|
|
|
this.picking_type_id = init_hash.picking_type_id ? init_hash.picking_type_id:0;
|
|
|
|
this.picking_id = init_hash.picking_id ? init_hash.picking_id:undefined;
|
2013-06-26 14:14:21 +00:00
|
|
|
this.picking = null;
|
2013-10-01 09:21:22 +00:00
|
|
|
this.pickings = [];
|
2014-03-04 09:20:23 +00:00
|
|
|
this.packoplines = null;
|
2013-06-27 09:58:27 +00:00
|
|
|
this.operations = null;
|
2013-11-15 12:54:28 +00:00
|
|
|
this.selected_operation = { id: null, picking_id: null};
|
2013-06-27 15:39:01 +00:00
|
|
|
this.packages = null;
|
2013-10-03 09:49:04 +00:00
|
|
|
this.barcode_scanner = new module.BarcodeScanner();
|
2014-03-20 15:40:56 +00:00
|
|
|
this.locations = [];
|
2014-03-24 15:56:28 +00:00
|
|
|
if(this.picking_id){
|
|
|
|
this.loaded = this.load(this.picking_id);
|
2013-10-03 09:49:04 +00:00
|
|
|
}else{
|
|
|
|
this.loaded = this.load();
|
|
|
|
}
|
2013-11-15 12:54:28 +00:00
|
|
|
|
2013-06-27 15:25:30 +00:00
|
|
|
},
|
2013-10-03 09:49:04 +00:00
|
|
|
|
|
|
|
// load the picking data from the server. If picking_id is undefined, it will take the first picking
|
|
|
|
// belonging to the category
|
2013-06-27 15:25:30 +00:00
|
|
|
load: function(picking_id){
|
|
|
|
var self = this;
|
|
|
|
|
2013-10-03 09:49:04 +00:00
|
|
|
|
|
|
|
function load_picking_list(type_id){
|
|
|
|
var pickings = new $.Deferred();
|
|
|
|
new instance.web.Model('stock.picking')
|
2014-03-24 15:56:28 +00:00
|
|
|
.call('get_next_picking_for_ui',[{'default_picking_type_id':parseInt(type_id)}])
|
2013-10-01 09:21:22 +00:00
|
|
|
.then(function(picking_ids){
|
|
|
|
if(!picking_ids || picking_ids.length === 0){
|
2013-09-25 13:09:58 +00:00
|
|
|
(new instance.web.Dialog(self,{
|
|
|
|
title: _t('No Picking Available'),
|
|
|
|
buttons: [{
|
|
|
|
text:_t('Ok'),
|
|
|
|
click: function(){
|
2014-02-11 15:51:57 +00:00
|
|
|
self.menu();
|
2013-09-25 13:09:58 +00:00
|
|
|
}
|
|
|
|
}]
|
|
|
|
}, _t('<p>We could not find a picking to display.</p>'))).open();
|
|
|
|
|
2013-10-03 09:49:04 +00:00
|
|
|
pickings.reject();
|
2013-09-25 13:09:58 +00:00
|
|
|
}else{
|
2013-10-01 09:21:22 +00:00
|
|
|
self.pickings = picking_ids;
|
2013-10-03 09:49:04 +00:00
|
|
|
pickings.resolve(picking_ids);
|
2013-09-25 13:09:58 +00:00
|
|
|
}
|
2013-06-28 16:20:26 +00:00
|
|
|
});
|
2013-10-03 09:49:04 +00:00
|
|
|
|
|
|
|
return pickings;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if we have a specified picking id, we load that one, and we load the picking of the same type as the active list
|
|
|
|
if( picking_id ){
|
|
|
|
var loaded_picking = new instance.web.Model('stock.picking')
|
|
|
|
.call('read',[[picking_id], [], new instance.web.CompoundContext()])
|
|
|
|
.then(function(picking){
|
|
|
|
self.picking = picking[0];
|
|
|
|
|
|
|
|
return load_picking_list(self.picking.picking_type_id[0]);
|
|
|
|
});
|
|
|
|
}else{
|
|
|
|
// if we don't have a specified picking id, we load the pickings belong to the specified type, and then we take
|
|
|
|
// the first one of that list as the active picking
|
|
|
|
var loaded_picking = new $.Deferred();
|
|
|
|
load_picking_list(self.picking_type_id)
|
|
|
|
.then(function(){
|
|
|
|
return new instance.web.Model('stock.picking').call('read',[self.pickings[0],[], new instance.web.CompoundContext()]);
|
|
|
|
})
|
|
|
|
.then(function(picking){
|
|
|
|
self.picking = picking;
|
2014-02-11 15:51:57 +00:00
|
|
|
self.picking_type_id = picking.picking_type_id[0];
|
2013-10-03 09:49:04 +00:00
|
|
|
loaded_picking.resolve();
|
|
|
|
});
|
2013-06-27 15:25:30 +00:00
|
|
|
}
|
|
|
|
|
2014-02-13 09:40:54 +00:00
|
|
|
return loaded_picking.then(function(){
|
2014-03-20 15:40:56 +00:00
|
|
|
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(){
|
2013-06-27 15:25:30 +00:00
|
|
|
|
2014-03-04 09:20:23 +00:00
|
|
|
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;
|
2013-06-27 09:58:27 +00:00
|
|
|
|
2013-06-27 16:47:54 +00:00
|
|
|
return new instance.web.Model('stock.pack.operation').call('read',[self.picking.pack_operation_ids, [], new instance.web.CompoundContext()]);
|
2013-06-27 09:58:27 +00:00
|
|
|
}).then(function(operations){
|
|
|
|
self.operations = operations;
|
2013-06-27 16:26:27 +00:00
|
|
|
var package_ids = [];
|
2013-06-27 14:00:54 +00:00
|
|
|
|
2013-06-27 16:26:27 +00:00
|
|
|
for(var i = 0; i < operations.length; i++){
|
|
|
|
if(!_.contains(package_ids,operations[i].result_package_id[0])){
|
2014-02-13 09:40:54 +00:00
|
|
|
if (operations[i].result_package_id[0]){
|
|
|
|
package_ids.push(operations[i].result_package_id[0]);
|
|
|
|
}
|
2013-06-27 16:26:27 +00:00
|
|
|
}
|
|
|
|
}
|
2013-06-27 16:47:54 +00:00
|
|
|
return new instance.web.Model('stock.quant.package').call('read',[package_ids, [], new instance.web.CompoundContext()]);
|
2013-06-27 14:00:54 +00:00
|
|
|
}).then(function(packages){
|
|
|
|
self.packages = packages;
|
2013-06-26 13:11:31 +00:00
|
|
|
});
|
2013-06-26 08:30:39 +00:00
|
|
|
},
|
|
|
|
start: function(){
|
2013-11-18 10:15:50 +00:00
|
|
|
this._super();
|
2013-06-26 08:30:39 +00:00
|
|
|
var self = this;
|
|
|
|
instance.webclient.set_content_full_screen(true);
|
2013-10-03 09:49:04 +00:00
|
|
|
this.barcode_scanner.connect(function(ean){
|
|
|
|
self.scan(ean);
|
|
|
|
});
|
2014-02-11 15:51:57 +00:00
|
|
|
|
2013-06-26 14:38:15 +00:00
|
|
|
this.$('.js_pick_quit').click(function(){ self.quit(); });
|
2013-10-01 09:21:22 +00:00
|
|
|
this.$('.js_pick_prev').click(function(){ self.picking_prev(); });
|
|
|
|
this.$('.js_pick_next').click(function(){ self.picking_next(); });
|
2013-10-03 09:49:04 +00:00
|
|
|
this.$('.js_pick_menu').click(function(){ self.menu(); });
|
2013-06-26 14:38:15 +00:00
|
|
|
|
2013-11-13 17:24:48 +00:00
|
|
|
this.hotkey_handler = function(event){
|
|
|
|
if(event.keyCode === 37 ){ // Left Arrow
|
|
|
|
self.picking_prev();
|
|
|
|
}else if(event.keyCode === 39){ // Right Arrow
|
|
|
|
self.picking_next();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
$('body').on('keyup',this.hotkey_handler);
|
|
|
|
|
2013-06-26 14:14:21 +00:00
|
|
|
$.when(this.loaded).done(function(){
|
2013-06-27 09:58:27 +00:00
|
|
|
self.picking_editor = new module.PickingEditorWidget(self);
|
|
|
|
self.picking_editor.replace(self.$('.oe_placeholder_picking_editor'));
|
2013-10-01 09:21:22 +00:00
|
|
|
|
|
|
|
if( self.picking.id === self.pickings[0]){
|
2014-02-26 16:10:03 +00:00
|
|
|
self.$('.js_pick_prev').addClass('disabled');
|
2013-10-01 09:21:22 +00:00
|
|
|
}else{
|
2014-02-26 16:10:03 +00:00
|
|
|
self.$('.js_pick_prev').removeClass('disabled');
|
2013-10-01 09:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( self.picking.id === self.pickings[self.pickings.length-1] ){
|
2014-02-26 16:10:03 +00:00
|
|
|
self.$('.js_pick_next').addClass('disabled');
|
2013-10-01 09:21:22 +00:00
|
|
|
}else{
|
2014-02-26 16:10:03 +00:00
|
|
|
self.$('.js_pick_next').removeClass('disabled');
|
2013-10-01 09:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-02-13 09:40:54 +00:00
|
|
|
}).fail(function(error) {console.log(error);});
|
2013-06-26 08:30:39 +00:00
|
|
|
|
|
|
|
},
|
2014-03-04 16:44:46 +00:00
|
|
|
on_searchbox: function(query){
|
|
|
|
var self = this;
|
2014-03-19 10:07:58 +00:00
|
|
|
self.picking_editor.on_searchbox(query.toUpperCase());
|
2014-03-04 16:44:46 +00:00
|
|
|
},
|
2013-06-27 15:25:30 +00:00
|
|
|
// reloads the data from the provided picking and refresh the ui.
|
|
|
|
// (if no picking_id is provided, gets the first picking in the db)
|
|
|
|
refresh_ui: function(picking_id){
|
|
|
|
var self = this;
|
2014-03-24 10:46:21 +00:00
|
|
|
var remove_search_filter = "";
|
2014-03-06 13:38:55 +00:00
|
|
|
if (self.picking.id === picking_id){
|
2014-03-24 10:46:21 +00:00
|
|
|
remove_search_filter = self.$('.oe_searchbox').val();
|
2014-03-06 13:38:55 +00:00
|
|
|
}
|
2013-06-27 15:25:30 +00:00
|
|
|
return this.load(picking_id)
|
2014-03-06 13:38:55 +00:00
|
|
|
.then(function(){
|
2014-03-19 10:07:58 +00:00
|
|
|
self.picking_editor.remove_blink();
|
2013-06-27 15:25:30 +00:00
|
|
|
self.picking_editor.renderElement();
|
2013-11-14 14:43:54 +00:00
|
|
|
|
2013-10-01 09:21:22 +00:00
|
|
|
if( self.picking.id === self.pickings[0]){
|
2014-02-26 16:10:03 +00:00
|
|
|
self.$('.js_pick_prev').addClass('disabled');
|
2013-10-01 09:21:22 +00:00
|
|
|
}else{
|
2014-02-26 16:10:03 +00:00
|
|
|
self.$('.js_pick_prev').removeClass('disabled');
|
2013-10-01 09:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( self.picking.id === self.pickings[self.pickings.length-1] ){
|
2014-02-26 16:10:03 +00:00
|
|
|
self.$('.js_pick_next').addClass('disabled');
|
2013-10-01 09:21:22 +00:00
|
|
|
}else{
|
2014-02-26 16:10:03 +00:00
|
|
|
self.$('.js_pick_next').removeClass('disabled');
|
2013-10-01 09:21:22 +00:00
|
|
|
}
|
2014-03-24 10:46:21 +00:00
|
|
|
if (remove_search_filter === ""){
|
2014-03-06 13:38:55 +00:00
|
|
|
self.$('.oe_searchbox').val('');
|
|
|
|
self.on_searchbox('');
|
|
|
|
}
|
|
|
|
else{
|
2014-03-24 10:46:21 +00:00
|
|
|
self.$('.oe_searchbox').val(remove_search_filter);
|
|
|
|
self.on_searchbox(remove_search_filter);
|
2014-03-06 13:38:55 +00:00
|
|
|
}
|
2013-06-27 15:25:30 +00:00
|
|
|
});
|
|
|
|
},
|
2013-11-14 14:43:54 +00:00
|
|
|
get_header: function(){
|
|
|
|
if(this.picking){
|
2014-02-11 15:51:57 +00:00
|
|
|
return this.picking.name;
|
2013-11-14 14:43:54 +00:00
|
|
|
}else{
|
2014-02-11 15:51:57 +00:00
|
|
|
return '';
|
2013-11-14 14:43:54 +00:00
|
|
|
}
|
|
|
|
},
|
2013-10-03 09:49:04 +00:00
|
|
|
menu: function(){
|
2014-03-24 15:56:28 +00:00
|
|
|
$.bbq.pushState('#action=stock.menu');
|
|
|
|
$(window).trigger('hashchange');
|
2013-10-03 09:49:04 +00:00
|
|
|
},
|
2013-11-15 12:54:28 +00:00
|
|
|
scan: function(ean){ //scans a barcode, sends it to the server, then reload the ui
|
2013-06-27 09:58:27 +00:00
|
|
|
var self = this;
|
2014-03-24 10:46:21 +00:00
|
|
|
var product_visible_ids = this.picking_editor.get_visible_ids();
|
2013-06-26 14:14:21 +00:00
|
|
|
new instance.web.Model('stock.picking')
|
2014-03-24 10:46:21 +00:00
|
|
|
.call('process_barcode_from_ui', [self.picking.id, ean, product_visible_ids])
|
2014-03-07 16:37:47 +00:00
|
|
|
.then(function(result){
|
2014-03-10 16:57:07 +00:00
|
|
|
if (result.filter_loc !== false){
|
2014-03-07 16:37:47 +00:00
|
|
|
//check if we have receive a location as answer
|
|
|
|
if (result.filter_loc !== undefined){
|
2014-03-21 15:34:05 +00:00
|
|
|
var modal_loc_hidden = self.$('#js_LocationChooseModal').attr('aria-hidden');
|
2014-03-20 15:40:56 +00:00
|
|
|
if (modal_loc_hidden === "false"){
|
2014-03-21 15:34:05 +00:00
|
|
|
var line = self.$('#js_LocationChooseModal .js_loc_option[data-loc-id='+result.filter_loc_id+']').attr('selected','selected');
|
2014-03-20 15:40:56 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
self.$('.oe_searchbox').val(result.filter_loc);
|
|
|
|
self.on_searchbox(result.filter_loc);
|
|
|
|
}
|
2014-03-07 16:37:47 +00:00
|
|
|
}
|
|
|
|
}
|
2014-03-10 16:57:07 +00:00
|
|
|
if (result.operation_id !== false){
|
2014-03-19 10:07:58 +00:00
|
|
|
self.refresh_ui(self.picking.id).then(function(){
|
|
|
|
return self.picking_editor.blink(result.operation_id);
|
|
|
|
});
|
2014-03-07 16:37:47 +00:00
|
|
|
}
|
2013-11-15 12:54:28 +00:00
|
|
|
});
|
|
|
|
},
|
2014-03-24 10:46:21 +00:00
|
|
|
scan_product_id: function(product_id,increment,op_id){ //performs the same operation as a scan, but with product id instead
|
2013-11-15 12:54:28 +00:00
|
|
|
var self = this;
|
|
|
|
new instance.web.Model('stock.picking')
|
2014-03-24 10:46:21 +00:00
|
|
|
.call('process_product_id_from_ui', [self.picking.id, product_id, op_id, increment])
|
2014-03-10 16:57:07 +00:00
|
|
|
.then(function(result){
|
2013-06-27 15:25:30 +00:00
|
|
|
return self.refresh_ui(self.picking.id);
|
2013-06-26 14:14:21 +00:00
|
|
|
});
|
|
|
|
},
|
2013-06-27 14:15:43 +00:00
|
|
|
pack: function(){
|
|
|
|
var self = this;
|
2014-03-07 13:25:23 +00:00
|
|
|
var pack_op_ids = self.picking_editor.get_current_op_selection(false);
|
2014-03-06 13:38:55 +00:00
|
|
|
if (pack_op_ids.length !== 0){
|
|
|
|
new instance.web.Model('stock.picking')
|
|
|
|
.call('action_pack',[[[self.picking.id]], pack_op_ids])
|
|
|
|
.then(function(){
|
|
|
|
instance.session.user_context.current_package_id = false;
|
|
|
|
return self.refresh_ui(self.picking.id);
|
|
|
|
});
|
|
|
|
}
|
2013-06-27 15:25:30 +00:00
|
|
|
},
|
2014-03-07 13:25:23 +00:00
|
|
|
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(){
|
2014-03-21 15:34:05 +00:00
|
|
|
return self.refresh_ui(self.picking.id).then(function(){
|
|
|
|
if (self.picking_editor.check_done()){
|
|
|
|
return self.done();
|
|
|
|
}
|
|
|
|
});
|
2014-03-07 13:25:23 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2013-06-27 15:25:30 +00:00
|
|
|
done: function(){
|
|
|
|
var self = this;
|
|
|
|
new instance.web.Model('stock.picking')
|
2014-02-11 15:51:57 +00:00
|
|
|
.call('action_done_from_ui',[self.picking.id, {'default_picking_type_id': self.picking_type_id}])
|
|
|
|
.then(function(new_picking_ids){
|
|
|
|
if (new_picking_ids){
|
|
|
|
return self.refresh_ui(new_picking_ids[0]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 0;
|
|
|
|
}
|
2013-07-08 10:34:00 +00:00
|
|
|
});
|
|
|
|
},
|
2014-03-18 10:40:25 +00:00
|
|
|
create_lot: function(op_id){
|
|
|
|
var self = this;
|
|
|
|
new instance.web.Model('stock.pack.operation')
|
|
|
|
.call('create_and_assign_lot',[parseInt(op_id)])
|
|
|
|
.then(function(){
|
|
|
|
return self.refresh_ui(self.picking.id);
|
|
|
|
});
|
|
|
|
},
|
2014-03-20 15:40:56 +00:00
|
|
|
change_location: function(op_id, loc_id, is_src_dst){
|
|
|
|
var self = this;
|
|
|
|
var vals = {'location_dest_id': loc_id};
|
|
|
|
if (is_src_dst){
|
|
|
|
vals = {'location_id': loc_id};
|
|
|
|
}
|
|
|
|
new instance.web.Model('stock.pack.operation')
|
|
|
|
.call('write',[op_id, vals])
|
|
|
|
.then(function(){
|
|
|
|
return self.refresh_ui(self.picking.id);
|
|
|
|
});
|
|
|
|
},
|
2013-07-08 10:34:00 +00:00
|
|
|
print_package: function(package_id){
|
|
|
|
var self = this;
|
|
|
|
new instance.web.Model('stock.quant.package')
|
|
|
|
.call('action_print',[[package_id]])
|
|
|
|
.then(function(action){
|
|
|
|
return self.do_action(action);
|
2013-06-28 11:39:49 +00:00
|
|
|
});
|
|
|
|
},
|
2014-02-11 15:51:57 +00:00
|
|
|
print_picking: function(){
|
|
|
|
var self = this;
|
|
|
|
new instance.web.Model('stock.picking.type').call('read', [[self.picking_type_id], ['code'], new instance.web.CompoundContext()])
|
|
|
|
.then(function(pick_type){
|
2014-03-17 17:03:39 +00:00
|
|
|
new instance.web.Model('stock.picking').call('do_print_picking',[[self.picking.id]])
|
2014-02-11 15:51:57 +00:00
|
|
|
.then(function(action){
|
|
|
|
return self.do_action(action);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
2013-10-01 09:21:22 +00:00
|
|
|
picking_next: function(){
|
|
|
|
for(var i = 0; i < this.pickings.length; i++){
|
|
|
|
if(this.pickings[i] === this.picking.id){
|
|
|
|
if(i < this.pickings.length -1){
|
2014-03-24 15:56:28 +00:00
|
|
|
$.bbq.pushState('picking_id='+this.pickings[i+1]);
|
2014-03-19 10:07:58 +00:00
|
|
|
this.refresh_ui(this.pickings[i+1]);
|
|
|
|
return;
|
2013-10-01 09:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
picking_prev: function(){
|
|
|
|
for(var i = 0; i < this.pickings.length; i++){
|
|
|
|
if(this.pickings[i] === this.picking.id){
|
|
|
|
if(i > 0){
|
2014-03-24 15:56:28 +00:00
|
|
|
$.bbq.pushState('picking_id='+this.pickings[i-1]);
|
2014-03-19 10:07:58 +00:00
|
|
|
this.refresh_ui(this.pickings[i-1]);
|
2013-10-01 09:21:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-03-18 10:40:25 +00:00
|
|
|
delete_package_op: function(pack_id){
|
|
|
|
var self = this;
|
|
|
|
new instance.web.Model('stock.pack.operation').call('search', [[['result_package_id', '=', pack_id]]])
|
|
|
|
.then(function(op_ids) {
|
|
|
|
new instance.web.Model('stock.pack.operation').call('write', [op_ids, {'result_package_id':false}])
|
|
|
|
.then(function() {
|
|
|
|
return self.refresh_ui(self.picking.id);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
2014-03-10 16:57:07 +00:00
|
|
|
set_operation_quantity: function(quantity, op_id){
|
2013-06-28 15:15:03 +00:00
|
|
|
var self = this;
|
2014-03-10 16:57:07 +00:00
|
|
|
if(quantity >= 0){
|
2013-06-28 15:15:03 +00:00
|
|
|
new instance.web.Model('stock.pack.operation')
|
2014-03-10 16:57:07 +00:00
|
|
|
.call('write',[[op_id],{'qty_done': quantity }])
|
2013-06-28 15:15:03 +00:00
|
|
|
.then(function(){
|
|
|
|
self.refresh_ui(self.picking.id);
|
|
|
|
});
|
2014-03-10 16:57:07 +00:00
|
|
|
}
|
2013-06-28 15:15:03 +00:00
|
|
|
|
2013-06-28 14:40:19 +00:00
|
|
|
},
|
2013-06-26 14:38:15 +00:00
|
|
|
quit: function(){
|
2013-10-03 09:49:04 +00:00
|
|
|
this.destroy();
|
2014-02-26 16:10:03 +00:00
|
|
|
return new instance.web.Model("ir.model.data").get_func("search_read")([['name', '=', 'action_picking_type_form']], ['res_id']).pipe(function(res) {
|
|
|
|
window.location = '/web#action=' + res[0]['res_id'];
|
|
|
|
});
|
2013-06-26 14:38:15 +00:00
|
|
|
},
|
2013-10-03 09:49:04 +00:00
|
|
|
destroy: function(){
|
|
|
|
this._super();
|
2014-03-10 16:57:07 +00:00
|
|
|
// this.disconnect_numpad();
|
2013-10-03 09:49:04 +00:00
|
|
|
this.barcode_scanner.disconnect();
|
2013-11-13 17:24:48 +00:00
|
|
|
$('body').off('keyup',this.hotkey_handler);
|
2013-10-03 09:49:04 +00:00
|
|
|
instance.webclient.set_content_full_screen(false);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
openerp.web.client_actions.add('stock.ui', 'instance.stock.PickingMainWidget');
|
|
|
|
|
|
|
|
module.BarcodeScanner = instance.web.Class.extend({
|
|
|
|
connect: function(callback){
|
|
|
|
var code = "";
|
|
|
|
var timeStamp = 0;
|
|
|
|
var timeout = null;
|
|
|
|
|
|
|
|
this.handler = function(e){
|
|
|
|
if(e.which === 13){ //ignore returns
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(timeStamp + 50 < new Date().getTime()){
|
|
|
|
code = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
timeStamp = new Date().getTime();
|
|
|
|
clearTimeout(timeout);
|
|
|
|
|
|
|
|
code += String.fromCharCode(e.which);
|
|
|
|
|
|
|
|
timeout = setTimeout(function(){
|
|
|
|
if(code.length >= 3){
|
|
|
|
callback(code);
|
|
|
|
}
|
|
|
|
code = "";
|
|
|
|
},100);
|
|
|
|
};
|
|
|
|
|
|
|
|
$('body').on('keypress', this.handler);
|
|
|
|
|
|
|
|
},
|
|
|
|
disconnect: function(){
|
|
|
|
$('body').off('keypress', this.handler);
|
|
|
|
},
|
2013-06-26 08:30:39 +00:00
|
|
|
});
|
2013-10-03 09:49:04 +00:00
|
|
|
|
2013-06-26 08:30:39 +00:00
|
|
|
}
|
2014-02-11 15:51:57 +00:00
|
|
|
|
|
|
|
openerp.stock = function(openerp) {
|
|
|
|
openerp.stock = openerp.stock || {};
|
|
|
|
openerp_picking_widgets(openerp);
|
2014-03-18 10:40:25 +00:00
|
|
|
}
|