diff --git a/addons/stock/static/src/js/stock_picking_type.js b/addons/stock/static/src/js/stock_picking_type.js
index 5e3ed0b5842..8996a210b2e 100644
--- a/addons/stock/static/src/js/stock_picking_type.js
+++ b/addons/stock/static/src/js/stock_picking_type.js
@@ -1,9 +1,12 @@
openerp.stock = function(openerp) {
+ var _t = openerp.web._t;
+
openerp.stock.SparklineBarWidget = openerp.web_kanban.AbstractField.extend({
className: "oe_sparkline_bar",
start: function() {
var self = this;
var title = this.$node.html();
+ console.log('mlklm')
setTimeout(function () {
var value = _.pluck(self.field.value, 'value');
var tooltips = _.pluck(self.field.value, 'tooltip');
@@ -19,6 +22,46 @@ openerp.stock = function(openerp) {
}, 0);
},
});
+
+ openerp.stock.GaugeWidget = openerp.web_kanban.AbstractField.extend({
+ className: "oe_gage",
+ start: function() {
+ var self = this;
+
+ var parent = this.getParent();
+ var max = 100;
+ var label = this.options.label_field ? parent.record[this.options.label_field].raw_value : "";
+ var title = this.$node.html();
+ var val = this.field.value;
+ var value = _.isArray(val) && val.length ? val[val.length-1]['value'] : val;
+ var unique_id = _.uniqueId("JustGage");
+
+ this.$el.empty()
+ .attr('style', this.$node.attr('style') + ';position:relative; display:inline-block;')
+ .attr('id', unique_id);
+ this.gage = new JustGage({
+ id: unique_id,
+ node: this.$el[0],
+ title: title,
+ value: value,
+ min: 0,
+ max: max,
+ relativeGaugeSize: true,
+ humanFriendly: true,
+ titleFontColor: '#333333',
+ valueFontColor: '#333333',
+ labelFontColor: '#000',
+ label: label,
+ levelColors: [
+ "#ff0000",
+ "#f9c802",
+ "#a9d70b"
+ ],
+ });
+ },
+ });
+
openerp.web_kanban.fields_registry.add("stock_sparkline_bar", "openerp.stock.SparklineBarWidget");
+ openerp.web_kanban.fields_registry.add("stock_gage", "openerp.stock.GaugeWidget");
};
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 074af8e0dcd..4c33b26bf6d 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -2328,13 +2328,20 @@ class stock_picking_type(osv.osv):
'count_picking_backorders': [('backorder_id','<>', False)],
}
result = {}
- for field in field_names:
+ for field in domains:
data = obj.read_group(cr, uid, domains[field] +
[('state', 'not in',('done','cancel','draft')), ('picking_type_id', 'in', ids)],
['picking_type_id'], ['picking_type_id'], context=context)
count = dict(map(lambda x: (x['picking_type_id'], x['__count']), data))
for tid in ids:
result.setdefault(tid, {})[field] = count.get(tid, 0)
+ for tid in ids:
+ if result[tid]['count_picking']:
+ result[tid]['rate_picking_late'] = result[tid]['count_picking_late'] *100 / result[tid]['count_picking']
+ result[tid]['rate_picking_backorders'] = result[tid]['count_picking_backorders'] *100 / result[tid]['count_picking']
+ else:
+ result[tid]['rate_picking_late'] = 0
+ result[tid]['rate_picking_backorders'] = 0
return result
def _get_picking_history(self, cr, uid, ids, field_names, arg, context=None):
@@ -2374,6 +2381,11 @@ class stock_picking_type(osv.osv):
'count_picking_backorders': fields.function(_get_picking_count,
type='integer', multi='_get_picking_count'),
+ 'rate_picking_late': fields.function(_get_picking_count,
+ type='integer', multi='_get_picking_count'),
+ 'rate_picking_backorders': fields.function(_get_picking_count,
+ type='integer', multi='_get_picking_count'),
+
'latest_picking_late': fields.function(_get_picking_history,
type='string', multi='_get_picking_history'),
'latest_picking_backorders': fields.function(_get_picking_history,
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index e201be8cbd3..b92e22758cd 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -1212,7 +1212,7 @@