summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/graph
diff options
context:
space:
mode:
authorMathieu Duckerts-Antoine <dam@odoo.com>2018-04-05 13:53:59 +0200
committerGéry Debongnie <ged@odoo.com>2018-04-05 15:59:40 +0200
commit5144414a3a67d2c02989936831c792772361964c (patch)
treea5c01d800f65ef19ce99a716906d2393977a8777 /addons/web/static/src/js/views/graph
parentb67331fc18109d013624e6c11ba52d0c61c17975 (diff)
[IMP] web: graph views can now aggregate many2ones
The read_group method was recently modified to allow more flexibility. With this commit, we add the possibility of aggregating many2one fields. These fields can be aggregating by counting the number of distinct IDs, directly in postgres. Also, note that we had to modify the mock server to implement the corresponding functionality.
Diffstat (limited to 'addons/web/static/src/js/views/graph')
-rw-r--r--addons/web/static/src/js/views/graph/graph_model.js7
-rw-r--r--addons/web/static/src/js/views/graph/graph_view.js2
2 files changed, 7 insertions, 2 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 0518e279637..f73a40d6b47 100644
--- a/addons/web/static/src/js/views/graph/graph_model.js
+++ b/addons/web/static/src/js/views/graph/graph_model.js
@@ -125,7 +125,12 @@ return AbstractModel.extend({
return groupBy.split(':')[0];
});
if (this.chart.measure !== '__count__') {
- fields = fields.concat(this.chart.measure);
+ if (this.fields[this.chart.measure].type === 'many2one') {
+ fields = fields.concat(this.chart.measure + ":count_distinct");
+ }
+ else {
+ fields = fields.concat(this.chart.measure);
+ }
}
return this._rpc({
model: this.modelName,
diff --git a/addons/web/static/src/js/views/graph/graph_view.js b/addons/web/static/src/js/views/graph/graph_view.js
index feb151b02e7..8cfe2dc0272 100644
--- a/addons/web/static/src/js/views/graph/graph_view.js
+++ b/addons/web/static/src/js/views/graph/graph_view.js
@@ -57,7 +57,7 @@ var GraphView = AbstractView.extend({
var measures = {__count__: {string: _t("Count"), type: "integer"}};
_.each(this.fields, function (field, name) {
if (name !== 'id' && field.store === true) {
- if (field.type === 'integer' || field.type === 'float' || field.type === 'monetary') {
+ if (field.type === 'integer' || field.type === 'float' || field.type === 'monetary' || field.type === 'many2one') {
measures[name] = field;
}
}