diff options
Diffstat (limited to 'addons/web/static/src/js/views/graph/graph_model.js')
| -rw-r--r-- | addons/web/static/src/js/views/graph/graph_model.js | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/addons/web/static/src/js/views/graph/graph_model.js b/addons/web/static/src/js/views/graph/graph_model.js index 3c1d26ea252..6d50dd8c269 100644 --- a/addons/web/static/src/js/views/graph/graph_model.js +++ b/addons/web/static/src/js/views/graph/graph_model.js @@ -135,6 +135,7 @@ return AbstractModel.extend({ var fields = _.map(groupedBy, function (groupBy) { return groupBy.split(':')[0]; }); + if (this.chart.measure !== '__count__') { if (this.fields[this.chart.measure].type === 'many2one') { fields = fields.concat(this.chart.measure + ":count_distinct"); @@ -143,10 +144,12 @@ return AbstractModel.extend({ fields = fields.concat(this.chart.measure); } } + + var context = _.extend({fill_temporal: true}, this.chart.context); return this._rpc({ model: this.modelName, method: 'read_group', - context: this.chart.context, + context: context, domain: this.chart.domain, fields: fields, groupBy: groupedBy, @@ -176,7 +179,8 @@ return AbstractModel.extend({ labels = _.map(this.chart.groupedBy, function (field) { return self._sanitizeValue(data_pt[field], field); }); - var value = is_count ? data_pt.__count || data_pt[this.chart.groupedBy[0]+'_count'] : data_pt[this.chart.measure]; + var count = data_pt.__count || data_pt[this.chart.groupedBy[0]+'_count'] || 0; + var value = is_count ? count : data_pt[this.chart.measure]; if (value instanceof Array) { // when a many2one field is used as a measure AND as a grouped // field, bad things happen. The server will only return the @@ -188,8 +192,9 @@ return AbstractModel.extend({ value = 1; } this.chart.data.push({ + count: count, value: value, - labels: labels + labels: labels, }); } }, @@ -203,7 +208,9 @@ return AbstractModel.extend({ */ _sanitizeValue: function (value, field) { var fieldName = field.split(':')[0]; - if (value === false && this.fields[fieldName].type !== 'boolean') return _t("Undefined"); + if (value === false && this.fields[fieldName].type !== 'boolean') { + return undefined; + } if (value instanceof Array) return value[1]; if (field && (this.fields[fieldName].type === 'selection')) { var selected = _.where(this.fields[fieldName].selection, {0: value})[0]; |
