Skip to content
Permalink
Browse files

[FIX] board: support group_by as string in action

the group by key in action context can be a single string
containing the name of a single field or a list of string
reprenting a list of field names

Before this commit, the board did not take this into account

After this commit, it does and supports both expressions

OPW 1956130

closes #32471

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
  • Loading branch information...
kebeclibre committed Apr 12, 2019
1 parent ce3d83f commit 9787abaeb0778c6df3b789d713102677fc29844c
Showing with 39 additions and 1 deletion.
  1. +1 −1 addons/board/static/src/js/board_view.js
  2. +38 −0 addons/board/static/tests/dashboard_tests.js
@@ -271,7 +271,7 @@ var BoardRenderer = FormRenderer.extend({
searchQuery: {
context: context,
domain: domain,
groupBy: context.group_by || [],
groupBy: typeof context.group_by === 'string' && context.group_by ? [context.group_by] : context.group_by || [],
orderedBy: context.orderedBy || [],
},
withControlPanel: false,
@@ -949,6 +949,44 @@ QUnit.test("Dashboard should use correct groupby", function (assert) {
form.destroy();
});

QUnit.test("Dashboard should use correct groupby when defined as a string of one field", function (assert) {
assert.expect(1);
var form = createView({
View: BoardView,
model: 'board',
data: this.data,
arch: '<form string="My Dashboard">' +
'<board style="2-1">' +
'<column>' +
'<action context="{\'group_by\': \'bar\'}" string="ABC" name="51"></action>' +
'</column>' +
'</board>' +
'</form>',
mockRPC: function (route, args) {
if (args.method === 'read_group') {
assert.deepEqual(args.kwargs.groupby, ['bar'],
'user defined groupby should have precedence on action groupby');
}
if (route === '/web/action/load') {
return $.when({
res_model: 'partner',
context: {
group_by: 'some_field',
},
views: [[4, 'list']],
});
}
return this._super.apply(this, arguments);
},
archs: {
'partner,4,list':
'<list string="Partner"><field name="foo"/></list>',
},
});

form.destroy();
});

QUnit.test('click on a cell of pivot view inside dashboard', function (assert) {
assert.expect(3);

0 comments on commit 9787aba

Please sign in to comment.
You can’t perform that action at this time.