From 4855b52c550fd305a226dc66eea8466ae34a0f4e Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Thu, 22 Aug 2019 09:58:23 +0000 Subject: [PATCH] [FIX] web: graph: id not in groupby Before this commit, when having the field "id" in the graph view it was selected to group by on it. This doesn't really make sense, and triggers an sql error anyway After this commit, we filter out that field from the groupbys OPW 2053444 closes odoo/odoo#35958 Signed-off-by: Lucas Perais (lpe) --- .../static/src/js/views/graph/graph_view.js | 3 +++ addons/web/static/tests/views/graph_tests.js | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) 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 a5ad21e1816..e850b629710 100644 --- a/addons/web/static/src/js/views/graph/graph_view.js +++ b/addons/web/static/src/js/views/graph/graph_view.js @@ -43,6 +43,9 @@ var GraphView = AbstractView.extend({ viewInfo.fields = _.defaults({__count__: {string: _t("Count"), type: "integer"}}, viewInfo.fields); viewInfo.arch.children.forEach(function (field) { var name = field.attrs.name; + if (name === "id") { + return; + } if (field.attrs.interval) { name += ':' + field.attrs.interval; } diff --git a/addons/web/static/tests/views/graph_tests.js b/addons/web/static/tests/views/graph_tests.js index 1e5edef4df3..da9384f72e8 100644 --- a/addons/web/static/tests/views/graph_tests.js +++ b/addons/web/static/tests/views/graph_tests.js @@ -105,6 +105,27 @@ QUnit.module('Views', { graph.destroy(); }); + QUnit.test('field id not in groupBy', function (assert) { + assert.expect(1); + + var graph = createView({ + View: GraphView, + model: "foo", + data: this.data, + arch: '' + + '' + + '', + mockRPC: function (route, args) { + if (args.method === 'read_group') { + assert.deepEqual(args.kwargs.groupby, [], + 'groupby should not contain id field'); + } + return this._super.apply(this, arguments); + } + }); + graph.destroy(); + }); + QUnit.test('switching mode', function (assert) { assert.expect(6);