parent
db55e2488c
commit
dab9cfdc1d
|
@ -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");
|
||||
|
||||
};
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -1212,7 +1212,7 @@
|
|||
<t t-esc="record.name.raw_value"/>
|
||||
</a>
|
||||
<a name="%(action_picking_tree)d" type="action" class="oe_sparkline_bar_link">
|
||||
<field name="weekly_picking" widget="stock_sparkline_bar"/>
|
||||
<field name="weekly_picking" widget="stock_sparkline_bar">Weekly Pickings</field>
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
|
@ -1235,6 +1235,12 @@
|
|||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="oe_center">
|
||||
<field name="rate_picking_late" widget="stock_gage" style="width:160px; height: 120px;">Late</field>
|
||||
<field name="rate_picking_backorders" widget="stock_gage" style="width:160px; height: 120px;">Backorders</field>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
@ -1244,7 +1250,7 @@
|
|||
</record>
|
||||
|
||||
<record id="action_picking_type_form" model="ir.actions.act_window">
|
||||
<field name="name">Picking Types</field>
|
||||
<field name="name">Inventory Moves</field>
|
||||
<field name="res_model">stock.picking.type</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="view_type">form</field>
|
||||
|
|
Loading…
Reference in New Issue