[WIP]barcode interface: add a modal window to change location
bzr revid: csn@openerp.com-20140320154056-137r0ts6umivzcrc
This commit is contained in:
parent
05cd763da9
commit
3e78262bb5
|
@ -28,6 +28,7 @@ html_template = """<!DOCTYPE html>
|
|||
<link rel="shortcut icon" href="/web/static/src/img/favicon.ico" type="image/x-icon"/>
|
||||
<link rel="stylesheet" href="/stock/static/src/css/barcode.css" />
|
||||
<link rel="stylesheet" href="/web/static/lib/bootstrap/css/bootstrap.css" />
|
||||
<link rel="stylesheet" href="/web/static/lib/jquery.ui/css/smoothness/jquery-ui-1.9.1.custom.css" />
|
||||
<link rel="stylesheet" href="/web/static/lib/fontawesome/css/font-awesome.css" />
|
||||
%(js)s
|
||||
<script type="text/javascript">
|
||||
|
|
|
@ -128,88 +128,4 @@ body{
|
|||
-moz-border-radius-bottomleft: 8px;
|
||||
border-bottom-right-radius: 8px;
|
||||
border-bottom-left-radius: 8px;
|
||||
}
|
||||
|
||||
.openerp.ui-dialog {
|
||||
display: none;
|
||||
height: auto !important;
|
||||
padding: 6px;
|
||||
background-color: rgba(60, 60, 60, 0.7);
|
||||
border: 1px solid;
|
||||
border-color: #888888 #555555 #444444;
|
||||
-moz-border-radius: 8px;
|
||||
-webkit-border-radius: 8px;
|
||||
border-radius: 8px;
|
||||
-moz-box-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
|
||||
-webkit-box-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
|
||||
box-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
|
||||
-webkit-background-clip: padding-box;
|
||||
-moz-background-clip: padding-box;
|
||||
background-clip: padding-box;
|
||||
}
|
||||
.openerp.ui-dialog .ui-dialog-content {
|
||||
padding: 0;
|
||||
}
|
||||
.openerp.ui-dialog .ui-dialog-titlebar, .openerp.ui-dialog .ui-dialog-content, .openerp.ui-dialog .ui-dialog-buttonpane {
|
||||
padding: 16px;
|
||||
}
|
||||
.openerp.ui-dialog .ui-dialog-titlebar {
|
||||
border-top: none;
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
border-bottom: 1px solid #cacaca;
|
||||
-moz-border-radius: 2px 2px 0 0;
|
||||
-webkit-border-radius: 2px 2px 0 0;
|
||||
border-radius: 2px 2px 0 0;
|
||||
background-color: #ededed;
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#fcfcfc), to(#dedede));
|
||||
background-image: -webkit-linear-gradient(top, #fcfcfc, #dedede);
|
||||
background-image: -moz-linear-gradient(top, #fcfcfc, #dedede);
|
||||
background-image: -ms-linear-gradient(top, #fcfcfc, #dedede);
|
||||
background-image: -o-linear-gradient(top, #fcfcfc, #dedede);
|
||||
background-image: linear-gradient(to bottom, #fcfcfc, #dedede);
|
||||
}
|
||||
.openerp.ui-dialog .ui-dialog-titlebar .ui-dialog-title {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.openerp.ui-dialog .ui-dialog-content {
|
||||
background: white;
|
||||
width: auto !important;
|
||||
}
|
||||
.openerp.ui-dialog .ui-dialog-buttonpane {
|
||||
border-top: 1px solid #e0e0e0;
|
||||
background: #f5f7f9;
|
||||
margin: 0;
|
||||
-moz-border-radius: 0 0 2px 2px;
|
||||
-webkit-border-radius: 0 0 2px 2px;
|
||||
border-radius: 0 0 2px 2px;
|
||||
}
|
||||
.openerp.ui-dialog .ui-dialog-buttonpane button {
|
||||
margin: 0 4px 0 0;
|
||||
}
|
||||
.openerp.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
|
||||
float: left;
|
||||
}
|
||||
.openerp.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset .ui-button {
|
||||
margin-right: 4px;
|
||||
}
|
||||
.openerp.ui-dialog .ui-dialog-titlebar-close {
|
||||
display: none;
|
||||
}
|
||||
.openerp.ui-dialog .ui-dialog-titlebar-close:before {
|
||||
content: "×";
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
line-height: 16px;
|
||||
color: black;
|
||||
text-shadow: 0 1px 0 white;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
}
|
||||
.openerp.ui-dialog .ui-dialog-titlebar-close:before:hover {
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
}
|
|
@ -33,6 +33,15 @@ function openerp_picking_widgets(instance){
|
|||
};
|
||||
});
|
||||
},
|
||||
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;
|
||||
},
|
||||
get_rows: function(){
|
||||
var model = this.getParent();
|
||||
this.rows = [];
|
||||
|
@ -174,7 +183,39 @@ function openerp_picking_widgets(instance){
|
|||
});
|
||||
this.$('.js_qty').blur(function(){
|
||||
this.value = "";
|
||||
})
|
||||
});
|
||||
this.$('.js_change_src').click(function(){
|
||||
var op_id = $(this)[0].attributes.getNamedItem('op_id').value;
|
||||
self.$('#js_loc_select').addClass('source');
|
||||
self.$('#js_loc_select').attr('op_id',op_id);
|
||||
self.$el.siblings('#js_LocationChooseModal').modal();
|
||||
});
|
||||
this.$('.js_change_dst').click(function(){
|
||||
var op_id = $(this)[0].attributes.getNamedItem('op_id').value;
|
||||
self.$('#js_loc_select').attr('op_id',op_id);
|
||||
self.$el.siblings('#js_LocationChooseModal').modal();
|
||||
});
|
||||
this.$('.js_validate_location').click(function(){
|
||||
//get current selection
|
||||
var select_dom_element = self.$('#js_loc_select');
|
||||
var selected = self.$('#js_loc_select option:selected')[0].attributes.getNamedItem('loc_id').value;
|
||||
var src_dst = false;
|
||||
var op_id = parseInt(select_dom_element[0].attributes.getNamedItem('op_id').value);
|
||||
if (select_dom_element[0].classList.contains('source')){
|
||||
src_dst = true;
|
||||
select_dom_element.removeClass('source');
|
||||
}
|
||||
if (selected === "false"){
|
||||
//close window
|
||||
self.$el.siblings('#js_LocationChooseModal').modal('hide');
|
||||
}
|
||||
else{
|
||||
loc_id = parseInt(selected);
|
||||
self.$el.siblings('#js_LocationChooseModal').modal('hide');
|
||||
self.getParent().change_location(op_id, loc_id, src_dst);
|
||||
|
||||
}
|
||||
});
|
||||
//remove navigtion bar from default openerp GUI
|
||||
$('td.navbar').html('<div></div>');
|
||||
},
|
||||
|
@ -218,7 +259,6 @@ function openerp_picking_widgets(instance){
|
|||
this.$('.js_pack_op_line.blink_me').removeClass('blink_me');
|
||||
},
|
||||
blink: function(op_id){
|
||||
console.log('blink: '+op_id);
|
||||
this.$('.js_pack_op_line[data-id="'+op_id+'"]').addClass('blink_me');
|
||||
},
|
||||
});
|
||||
|
@ -226,9 +266,6 @@ function openerp_picking_widgets(instance){
|
|||
module.PickingMenuWidget = module.MobileWidget.extend({
|
||||
template: 'PickingMenuWidget',
|
||||
init: function(parent, params){
|
||||
$(window).bind('hashchange', function(){
|
||||
console.log($.bbq.getState());
|
||||
});
|
||||
this._super(parent,params);
|
||||
var self = this;
|
||||
|
||||
|
@ -392,6 +429,7 @@ function openerp_picking_widgets(instance){
|
|||
this.packages = null;
|
||||
this.barcode_scanner = new module.BarcodeScanner();
|
||||
this.picking_type_id = params.context.active_id || 0;
|
||||
this.locations = [];
|
||||
|
||||
if(params.context.picking_id){
|
||||
this.loaded = this.load(params.context.picking_id);
|
||||
|
@ -458,6 +496,12 @@ 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('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){
|
||||
|
@ -479,7 +523,6 @@ function openerp_picking_widgets(instance){
|
|||
}).then(function(packages){
|
||||
self.packages = packages;
|
||||
});
|
||||
|
||||
},
|
||||
start: function(){
|
||||
this._super();
|
||||
|
@ -601,11 +644,16 @@ function openerp_picking_widgets(instance){
|
|||
if (result.filter_loc !== false){
|
||||
//check if we have receive a location as answer
|
||||
if (result.filter_loc !== undefined){
|
||||
self.$('.oe_searchbox').val(result.filter_loc);
|
||||
self.on_searchbox(result.filter_loc);
|
||||
var modal_loc_hidden = self.$('#js_LocationChooseModal')[0].attributes.getNamedItem('aria-hidden').value;
|
||||
if (modal_loc_hidden === "false"){
|
||||
var line = self.$('#js_LocationChooseModal .js_loc_option[loc_id='+result.filter_loc_id+']').attr('selected','selected');
|
||||
}
|
||||
else{
|
||||
self.$('.oe_searchbox').val(result.filter_loc);
|
||||
self.on_searchbox(result.filter_loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(result.operation_id);
|
||||
if (result.operation_id !== false){
|
||||
self.refresh_ui(self.picking.id).then(function(){
|
||||
return self.picking_editor.blink(result.operation_id);
|
||||
|
@ -665,6 +713,18 @@ function openerp_picking_widgets(instance){
|
|||
return self.refresh_ui(self.picking.id);
|
||||
});
|
||||
},
|
||||
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);
|
||||
});
|
||||
},
|
||||
print_package: function(package_id){
|
||||
var self = this;
|
||||
new instance.web.Model('stock.quant.package')
|
||||
|
@ -691,9 +751,6 @@ function openerp_picking_widgets(instance){
|
|||
}
|
||||
});
|
||||
},
|
||||
do_load_state: function(){
|
||||
debugger;
|
||||
},
|
||||
picking_next: function(){
|
||||
for(var i = 0; i < this.pickings.length; i++){
|
||||
if(this.pickings[i] === this.picking.id){
|
||||
|
|
|
@ -48,14 +48,40 @@
|
|||
|
||||
<t t-name='PickingEditorWidget'>
|
||||
|
||||
<div>
|
||||
<h3><strong>Operations
|
||||
<select id="js_select" class="form-control-group">
|
||||
<option id="js_select_todo">ToDo</option>
|
||||
<option id="js_select_processed">Processed</option>
|
||||
</select>
|
||||
</strong></h3>
|
||||
<div class="modal fade" id="js_LocationChooseModal" tabindex="-1" role="dialog" aria-labelledby="LocationChooseModal" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
|
||||
<h4 class="modal-title" id="myModalLabel">Choose a location</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Scan a location or select it in the list below</p>
|
||||
<select id="js_loc_select" class="form-control">
|
||||
<option class="js_loc_option" loc_id="false"></option>
|
||||
<t t-foreach="widget.get_location()" t-as="loc">
|
||||
<option class="js_loc_option" t-att-loc_id="loc.id"><t t-esc="loc.name"/></option>
|
||||
</t>
|
||||
</select>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-primary js_validate_location">Ok</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div>
|
||||
<h3><strong>Operations
|
||||
<select id="js_select">
|
||||
<option id="js_select_todo">ToDo</option>
|
||||
<option id="js_select_processed">Processed</option>
|
||||
</select>
|
||||
</strong></h3>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
|
@ -102,7 +128,7 @@
|
|||
</td>
|
||||
<td class="js_loc"> <t t-esc="row.cols.dest" />
|
||||
<div class="pull-right btn-group">
|
||||
<button type="button" class="btn btn-default dropdown-toggle fa fa-bars" data-toggle="dropdown">
|
||||
<button type="button" class="btn btn-default dropdown-toggle fa fa-cog" data-toggle="dropdown">
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
|
@ -110,8 +136,8 @@
|
|||
<li><a class="js_create_lot" t-att-product_id="row.cols.id" href="#">Create Lot</a></li>
|
||||
</t>
|
||||
<t t-if="!row.cols.head_container">
|
||||
<li><a class="js_change_src" t-att-pack_id="row.cols.id" href="#">Change source location</a></li>
|
||||
<li><a class="js_change_dst" t-att-pack_id="row.cols.id" href="#">Change destination location</a></li>
|
||||
<li><a class="js_change_src" t-att-op_id="row.cols.id" href="#">Change source location</a></li>
|
||||
<li><a class="js_change_dst" t-att-op_id="row.cols.id" href="#">Change destination location</a></li>
|
||||
</t>
|
||||
<t t-if="row.cols.head_container">
|
||||
<li><a class="js_delete_pack" t-att-pack_id="row.cols.id" href="#">Remove from package</a></li>
|
||||
|
|
|
@ -1274,8 +1274,8 @@ class stock_picking(osv.osv):
|
|||
#if we have a location, return immediatly with the location name
|
||||
location = stock_location_obj.browse(cr, uid, matching_location_ids[0], context=None)
|
||||
answer['filter_loc'] = stock_location_obj._name_get(cr, uid, location, context=None)
|
||||
answer['filter_loc_id'] = matching_location_ids[0]
|
||||
return answer
|
||||
# return {'filter_loc': stock_location_obj._name_get(cr, uid, location, context=None)}
|
||||
#check if the barcode correspond to a product
|
||||
matching_product_ids = product_obj.search(cr, uid, ['|', ('ean13', '=', barcode_str), ('default_code', '=', barcode_str)], context=context)
|
||||
if matching_product_ids:
|
||||
|
|
Loading…
Reference in New Issue