[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) <lpe@odoo.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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: '<graph string="Partners">' +
|
||||
'<field name="id"/>' +
|
||||
'</graph>',
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user