[IMP] stock_picking_ui: ability to select operation lines and modify their quantity

bzr revid: fva@openerp.com-20131115125428-jm0k0pksm90yuxb2
This commit is contained in:
Frédéric van der Essen
2013-11-15 13:54:28 +01:00
parent d6e81b1a92
commit f049e4e09a
3 changed files with 73 additions and 11 deletions
+6 -1
View File
@@ -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;
}
+63 -6
View File
@@ -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;
+4 -4
View File
@@ -59,7 +59,7 @@
<col class='oe_pick_col_small'></col>
<col class='oe_pick_col_small'></col>
<col class='oe_pick_col_expand'></col>
<col class='oe_pick_col_expand'></col>
<col class='oe_pick_col_small'></col>
</colgroup>
<thead>
@@ -69,7 +69,7 @@
<th class='oe_centeralign'>Rem</th>
<th class='oe_centeralign'>UoM</th>
<th>Location</th>
<th>Status</th>
<th>Scan</th>
</tr>
</thead>
@@ -81,7 +81,7 @@
<td class='oe_centeralign'> <t t-esc="row.cols.rem" /> </td>
<td class='oe_centeralign'> <t t-esc="row.cols.uom" /> </td>
<td> <t t-esc="row.cols.loc" /> </td>
<td> <t t-esc="row.cols.stat" /> </td>
<td><span class='oe_row_button oe_expanded js_pack_scan' t-att-op-id='row.cols.id'>➔</span></td>
</tr>
</t>
</tbody>
@@ -111,7 +111,7 @@
<tbody>
<t t-foreach="widget.get_rows()" t-as="row">
<tr t-att-class="row.classes">
<tr t-att-class="row.classes" t-att-op-id="row.att_op_id">
<td> <t t-esc="row.cols.product" /> </td>
<td class='oe_centeralign'> <t t-esc="row.cols.qty" /> </td>
<td class='oe_centeralign'> <t t-esc="row.cols.uom" /> </td>