[FIX] stock: barcode scanner GUI somewhat functionally working

bzr revid: qdp-launchpad@openerp.com-20140211155157-gu86q7it150u33tp
This commit is contained in:
Quentin (OpenERP) 2014-02-11 16:51:57 +01:00
parent e0362bf34c
commit ef8e1fc31f
6 changed files with 66 additions and 91 deletions

View File

@ -107,9 +107,6 @@ Dashboard / Reports for Warehouse Management will include:
'static/src/css/stock.css',
],
'js': [
'static/lib/sparkline/jquery.sparkline.js',
'static/lib/justgage.js',
'static/src/js/stock_picking_type.js',
'static/src/js/widgets.js',
],
'qweb': ['static/src/xml/picking.xml'],

View File

@ -223,7 +223,7 @@
* ----------------------- */
.oe_pick_widget .oe_searchbox{
float: right;
margin-top: 13px;
}
.oe_pick_widget .oe_searchbox input{
padding: 8px;

View File

@ -54,6 +54,9 @@ function openerp_picking_widgets(instance){
console.log('Id:',id);
self.getParent().scan_product_id(id);
});
//remove navigtion bar from default openerp GUI
$('td.navbar').html('<div></div>');
},
});
@ -159,7 +162,7 @@ function openerp_picking_widgets(instance){
}
self.pickings_by_type[0] = [];
return new instance.web.Model('stock.picking').call('search_read',[ [['state','in',['confirmed','assigned']]], [] ], {context: new instance.web.CompoundContext()});
return new instance.web.Model('stock.picking').call('search_read',[ [['state','in', ['assigned', 'partially_available']]], [] ], {context: new instance.web.CompoundContext()});
}).then(function(pickings){
self.pickings = pickings;
@ -182,6 +185,8 @@ function openerp_picking_widgets(instance){
this.$('.oe_searchbox input').keyup(function(event){
self.on_searchbox($(this).val());
});
//remove navigtion bar from default openerp GUI
$('td.navbar').html('<div></div>');
},
start: function(){
this._super();
@ -294,7 +299,6 @@ function openerp_picking_widgets(instance){
this.packages = null;
this.barcode_scanner = new module.BarcodeScanner();
this.picking_type_id = params.context.active_id || 0;
if(params.context.picking_id){
this.loaded = this.load(params.context.picking_id);
@ -312,7 +316,6 @@ function openerp_picking_widgets(instance){
function load_picking_list(type_id){
var pickings = new $.Deferred();
new instance.web.Model('stock.picking')
.call('get_next_picking_for_ui',[{'default_picking_type_id':type_id}])
.then(function(picking_ids){
@ -322,7 +325,7 @@ function openerp_picking_widgets(instance){
buttons: [{
text:_t('Ok'),
click: function(){
self.quit();
self.menu();
}
}]
}, _t('<p>We could not find a picking to display.</p>'))).open();
@ -356,6 +359,7 @@ function openerp_picking_widgets(instance){
})
.then(function(picking){
self.picking = picking;
self.picking_type_id = picking.picking_type_id[0];
loaded_picking.resolve();
});
}
@ -395,10 +399,12 @@ function openerp_picking_widgets(instance){
this.barcode_scanner.connect(function(ean){
self.scan(ean);
});
this.$('.js_pick_quit').click(function(){ self.quit(); });
this.$('.js_pick_pack').click(function(){ self.pack(); });
this.$('.js_pick_done').click(function(){ self.done(); });
this.$('.js_pick_print').click(function(){ self.print_picking(); });
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(); });
@ -439,8 +445,6 @@ function openerp_picking_widgets(instance){
});
return this._super();
},
// reloads the data from the provided picking and refresh the ui.
// (if no picking_id is provided, gets the first picking in the db)
@ -463,15 +467,14 @@ function openerp_picking_widgets(instance){
}else{
self.$('.js_pick_next').removeClass('oe_disabled');
}
self.$('.oe_pick_app_header').text(self.get_header());
});
},
get_header: function(){
if(this.picking){
return _t('Picking:') +' '+this.picking.name;
return this.picking.name;
}else{
return _t('Picking:');
return '';
}
},
menu: function(){
@ -515,9 +518,14 @@ function openerp_picking_widgets(instance){
done: function(){
var self = this;
new instance.web.Model('stock.picking')
.call('action_done_from_ui',[self.picking.id])
.then(function(new_picking_id){
return self.refresh_ui(new_picking_id);
.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;
}
});
},
print_package: function(package_id){
@ -528,6 +536,26 @@ function openerp_picking_widgets(instance){
return self.do_action(action);
});
},
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){
console.log('self.picking_type_id.code '+pick_type[0]['code']);
if (pick_type[0]['code'] == 'outgoing'){
new instance.web.Model('stock.picking').call('do_print_delivery',[[self.picking.id]])
.then(function(action){
return self.do_action(action);
});
}
else {
console.log('self.picking_id '+picking_id);
new instance.web.Model('stock.picking').call('do_print_picking',[[self.picking.id]])
.then(function(action){
return self.do_action(action);
});
}
});
},
picking_next: function(){
for(var i = 0; i < this.pickings.length; i++){
if(this.pickings[i] === this.picking.id){
@ -734,3 +762,11 @@ function openerp_picking_widgets(instance){
});
}
openerp.stock = function(openerp) {
openerp.stock = openerp.stock || {};
openerp_picking_widgets(openerp);
}

View File

@ -175,11 +175,14 @@
<table class='oe_pick_layout'>
<tr class='oe_pick_header_row'>
<td class='oe_pick_header'>
<div class='oe_pick_right_toolbar'>
<div class='oe_pick_button js_pick_quit'> Quit </div>
</div>
<div class='oe_pick_toolbar'>
<div class='oe_searchbox oe_left'>
<input type='text' placeholder='Search'/>
</div>
</div>
</td>
</tr>
<tr class='oe_pick_body_row'>
@ -187,10 +190,6 @@
<div class='oe_pick_body'>
<div class='oe_pick_app'>
<div class='oe_searchbox'>
<input type='text' placeholder='Search'/>
</div>
<h3 class='oe_pick_app_title'>Pickings</h3>
<div class='oe_picking_not_found oe_hidden'>
@ -208,7 +207,7 @@
<div t-att-class="'oe_picking ' + (widget.pickings_by_type[type.id].length === 0 ? 'oe_empty':'js_pick_last') "
t-att-data-id="type.id">
<span class='oe_picking_name'><t t-esc="type.name" /></span>
<span class='oe_picking_name'><t t-esc="type.complete_name" /></span>
<t t-if="widget.pickings_by_type[type.id].length === 0">
<span class='oe_pick_app_info'>Nothing to do</span>
</t>
@ -229,22 +228,19 @@
</div>
</t>
<t t-name="PickingMainWidget">
<div class='oe_pick_widget'>
<table class='oe_pick_layout'>
<tr class='oe_pick_header_row'>
<td class='oe_pick_header'>
<div class='oe_pick_right_toolbar'>
<div class='oe_pick_button js_pick_menu'> Menu </div>
<div class='oe_pick_button js_pick_quit'> Quit </div>
</div>
<div class='oe_pick_toolbar'>
<div class='oe_pick_button oe_small oe_disabled oe_left js_pick_prev'>&lt;</div>
<div class='oe_pick_button js_pick_pack'> Pack </div>
<div class='oe_pick_button js_pick_done'> Done </div>
<div class='oe_pick_button oe_small oe_disabled oe_right js_pick_next'>&gt;</div>
<div class='oe_pick_button oe_disabled js_pick_prev'>&lt; Previous</div>
<div class='oe_pick_button oe_disabled js_pick_next'>Next &gt;</div>
</div>
</td>
@ -253,10 +249,13 @@
<td class='oe_pick_body_cont'>
<div class='oe_pick_body'>
<div class='oe_pick_app'>
<div class='oe_pick_button js_pick_done'> Done </div>
<div class='oe_pick_button js_pick_print'> Print </div>
<div class='oe_pick_app_header'>
<t t-esc='widget.get_header()' />
</div>
<div class='oe_pick_button js_pick_pack'> Put in Pack </div>
<div class='oe_placeholder_picking_editor'></div>
<div class='oe_placeholder_package_editor'></div>
<div class='oe_placeholder_package_selector'></div>

View File

@ -596,7 +596,7 @@ class stock_picking(osv.osv):
_name = "stock.picking"
_inherit = ['mail.thread']
_description = "Picking List"
_order = "priority desc, date desc, id desc"
_order = "priority desc, date asc, id desc"
def _set_min_date(self, cr, uid, id, field, value, arg, context=None):
move_obj = self.pool.get("stock.move")
@ -1129,13 +1129,13 @@ class stock_picking(osv.osv):
""" returns the next pickings to process. Used in the barcode scanner UI"""
if context is None:
context = {}
domain = [('state', 'in', ('confirmed', 'assigned'))]
domain = [('state', 'in', ('assigned', 'partially_available'))]
if context.get('default_picking_type_id'):
domain.append(('picking_type_id', '=', context['default_picking_type_id']))
return self.search(cr, uid, domain, context=context)
def action_done_from_ui(self, cr, uid, picking_id, context=None):
""" called when button 'done' in pused in the barcode scanner UI """
""" called when button 'done' is pushed in the barcode scanner UI """
self.do_transfer(cr, uid, [picking_id], context=context)
#return id of next picking to work on
return self.get_next_picking_for_ui(cr, uid, context=context)
@ -3622,39 +3622,6 @@ class stock_picking_type(osv.osv):
_description = "The picking type determines the picking view"
_order = 'sequence'
def __get_bar_values(self, cr, uid, obj, domain, read_fields, value_field, groupby_field, context=None):
""" Generic method to generate data for bar chart values using SparklineBarWidget.
This method performs obj.read_group(cr, uid, domain, read_fields, groupby_field).
:param obj: the target model (i.e. crm_lead)
:param domain: the domain applied to the read_group
:param list read_fields: the list of fields to read in the read_group
:param str value_field: the field used to compute the value of the bar slice
:param str groupby_field: the fields used to group
:return list section_result: a list of dicts: [
{ 'value': (int) bar_column_value,
'tootip': (str) bar_column_tooltip,
}
]
"""
month_begin = date.today().replace(day=1)
section_result = [{
'value': 0,
'tooltip': (month_begin + relativedelta.relativedelta(months=i)).strftime('%B'),
} for i in range(-2, 2, 1)]
group_obj = obj.read_group(cr, uid, domain, read_fields, groupby_field, context=context)
for group in group_obj:
group_begin_date = datetime.strptime(group['__domain'][0][2], DEFAULT_SERVER_DATE_FORMAT)
month_delta = relativedelta.relativedelta(month_begin, group_begin_date)
section_result[-month_delta.months + 2] = {'value': group.get(value_field, 0), 'tooltip': group_begin_date.strftime('%B')}
inner_groupby = (group.get('__context', {})).get('group_by',[])
if inner_groupby:
groupby_picking = obj.read_group(cr, uid, group.get('__domain'), read_fields, inner_groupby, context=context)
for groupby in groupby_picking:
section_result[-month_delta.months + 2]['value'] = groupby.get(value_field, 0)
return section_result
def _get_tristate_values(self, cr, uid, ids, field_name, arg, context=None):
picking_obj = self.pool.get('stock.picking')
res = dict.fromkeys(ids, [])
@ -3672,24 +3639,6 @@ class stock_picking_type(osv.osv):
res[picking_type_id] = tristates
return res
def _get_monthly_pickings(self, cr, uid, ids, field_name, arg, context=None):
obj = self.pool.get('stock.picking')
res = dict.fromkeys(ids, False)
month_begin = date.today().replace(day=1)
groupby_begin = (month_begin + relativedelta.relativedelta(months=-2)).strftime(DEFAULT_SERVER_DATE_FORMAT)
groupby_end = (month_begin + relativedelta.relativedelta(months=2)).strftime(DEFAULT_SERVER_DATE_FORMAT)
for id in ids:
created_domain = [
('picking_type_id', '=', id),
('state', '=', 'done'),
('date', '>=', groupby_begin),
('date', '<', groupby_end),
]
res[id] = self.__get_bar_values(cr, uid, obj, created_domain, ['date', 'picking_type_id'], 'picking_type_id_count', ['date', 'picking_type_id'], context=context)
return res
def _get_picking_count(self, cr, uid, ids, field_names, arg, context=None):
obj = self.pool.get('stock.picking')
domains = {
@ -3799,9 +3748,6 @@ class stock_picking_type(osv.osv):
'active': fields.boolean('Active'),
# Statistics for the kanban view
'monthly_picking': fields.function(_get_monthly_pickings,
type='string',
string='Done Pickings per Month'),
'last_done_picking': fields.function(_get_tristate_values,
type='string',
string='Last 10 Done Pickings'),

View File

@ -1494,9 +1494,6 @@
</div>
<div>
<a name="%(action_picking_tree)d" type="action">All Operations</a>
<!--<a name="%(action_picking_tree_done_grouped)d" type="action" class="oe_sparkline_bar_link">
<field name="monthly_picking" widget="sparkline_bar">Monthly Done Operations</field>
</a>-->
</div>
</div>
<div class="oe_picking_type_gauge">