[IMP] stock.ui: package selection

bzr revid: fva@openerp.com-20130628095547-h8lms4nbdar8k55j
This commit is contained in:
Frédéric van der Essen
2013-06-28 11:55:47 +02:00
parent 2df2f80c5f
commit d8e3603ddc
3 changed files with 38 additions and 6 deletions
+6
View File
@@ -103,6 +103,9 @@
.oe_pick_widget .oe_pick_list_table tbody tr:nth-child(odd){
background: rgb(250,250,250);
}
.oe_pick_widget .oe_pick_list_table tbody tr.oe_selected{
background: rgb(236, 236, 247);
}
.oe_pick_widget .oe_pick_list_table td,
.oe_pick_widget .oe_pick_list_table th {
padding: 5px;
@@ -131,5 +134,8 @@
border: solid 1px rgba(0, 0, 0, 0.09);
cursor: pointer;
}
.oe_pick_widget .js-pack{
cursor: pointer;
}
+31 -5
View File
@@ -36,16 +36,16 @@ function openerp_picking_widgets(instance){
template: 'PackageEditorWidget',
get_header: function(){
var model = this.getParent();
var current_package_id = instance.session.user_context.current_package_id;
return current_package_id ? 'Current Operations for package: ' + current_package_id[1] : 'Current Operations';
var current_package = model.get_selected_package();
return current_package ? 'Operations for Package: ' + current_package.name : 'Current Operations';
},
get_rows: function(){
var current_package_id = instance.session.user_context.current_package_id;
var model = this.getParent();
var current_package = model.get_selected_package();
var rows = [];
_.each( model.operations, function(op){
if(current_package_id && op.package_id !== current_package_id){
if(current_package && op.package_id !== current_package.id){
return;
}
rows.push({
@@ -68,15 +68,24 @@ function openerp_picking_widgets(instance){
},
get_rows: function(){
var model = this.getParent();
var current_package = model.get_selected_package();
var rows = [];
_.each( model.packages, function(pack){
rows.push({
cols:{ pack: pack.name},
id: pack.id
id: pack.id,
classes: 'js-pack' + ( pack === current_package ? ' oe_selected' : '') ,
});
});
return rows;
},
renderElement: function(){
this._super();
var model = this.getParent();
this.$('.js-pack').click(function(){
model.select_package(parseInt($(this).attr('pack-id')));
});
},
});
module.PickingMainWidget = instance.web.Widget.extend({
@@ -205,6 +214,23 @@ function openerp_picking_widgets(instance){
console.log('New picking id:',new_picking_id);
});
},
select_package: function(package_id){
console.log('Select Package:',package_id);
instance.session.user_context.current_package_id = package_id;
this.package_editor.renderElement();
this.package_selector.renderElement();
},
get_selected_package: function(){
var current_package;
_.each( this.packages, function(pack){
if(pack.id === instance.session.user_context.current_package_id){
current_package = pack;
}
});
return current_package;
},
connect_barcode_scanner: function(){
var self =this;
var code = [];
+1 -1
View File
@@ -140,7 +140,7 @@
<tbody>
<t t-foreach="widget.get_rows()" t-as="row">
<tr t-att-class="row.classes" t-att-data-id="row.id">
<tr t-att-class="row.classes" t-att-pack-id="row.id">
<td> <t t-esc="row.cols.pack" /> </td>
<td class='oe_centeralign'> <span class='oe_row_button js_pick_plus'>+</span> </td>
<td class='oe_centeralign'> <span class='oe_row_button js_pick_minus'>-</span> </td>