diff --git a/addons/project/views/project_views.xml b/addons/project/views/project_views.xml
index 94067e2c14e..b583242e6f3 100644
--- a/addons/project/views/project_views.xml
+++ b/addons/project/views/project_views.xml
@@ -63,6 +63,7 @@
project.task
kanban,tree,form,calendar,pivot,graph,activity
{
+ 'pivot_row_groupby': ['user_id'],
'search_default_project_id': [active_id],
'default_project_id': active_id,
}
diff --git a/addons/web/static/src/js/views/pivot/pivot_model.js b/addons/web/static/src/js/views/pivot/pivot_model.js
index e28a5baed61..25aa4be7e26 100644
--- a/addons/web/static/src/js/views/pivot/pivot_model.js
+++ b/addons/web/static/src/js/views/pivot/pivot_model.js
@@ -383,7 +383,7 @@ var PivotModel = AbstractModel.extend({
comparisonTimeRangeDescription: params.comparisonTimeRangeDescription || "",
compare: params.compare || false,
context: _.extend({}, session.user_context, params.context),
- groupedBy: params.groupedBy,
+ groupedBy: params.context.pivot_row_groupby || params.groupedBy,
colGroupBys: params.context.pivot_column_groupby || params.colGroupBys,
measures: this._processMeasures(params.context.pivot_measures) || params.measures,
sorted_column: {},
diff --git a/addons/web/static/tests/views/pivot_tests.js b/addons/web/static/tests/views/pivot_tests.js
index acd8b11b635..975f68551fa 100644
--- a/addons/web/static/tests/views/pivot_tests.js
+++ b/addons/web/static/tests/views/pivot_tests.js
@@ -1293,6 +1293,45 @@ QUnit.module('Views', {
pivot.destroy();
});
+ QUnit.test('correctly uses pivot_row_groupby key with default groupBy from the context', async function (assert) {
+ assert.expect(6);
+
+ this.data.partner.fields.amount = {string: "Amount", type: "float"};
+
+ var pivot = await createView({
+ View: PivotView,
+ model: "partner",
+ data: this.data,
+ arch: '' +
+ '' +
+ '' +
+ '',
+ groupBy: ['customer'],
+ viewOptions: {
+ context: {
+ pivot_row_groupby: ['product_id'],
+ },
+ },
+ });
+
+ assert.strictEqual(pivot.$('thead .o_pivot_header_cell_opened').length, 1,
+ "column: should have one opened header");
+ assert.strictEqual(pivot.$('thead .o_pivot_header_cell_closed:contains(First)').length, 1,
+ "column: should display one closed header with 'First'");
+ assert.strictEqual(pivot.$('thead .o_pivot_header_cell_closed:contains(Second)').length, 1,
+ "column: should display one closed header with 'Second'");
+
+ // With pivot_row_groupby, groupBy customer should replace and eventually display product_id
+ assert.strictEqual(pivot.$('tbody .o_pivot_header_cell_opened').length, 1,
+ "row: should have one opened header");
+ assert.strictEqual(pivot.$('tbody .o_pivot_header_cell_closed:contains(xphone)').length, 1,
+ "row: should display one closed header with 'xphone'");
+ assert.strictEqual(pivot.$('tbody .o_pivot_header_cell_closed:contains(xpad)').length, 1,
+ "row: should display one closed header with 'xpad'");
+
+ pivot.destroy();
+ });
+
QUnit.test('pivot still handles __count__ measure', async function (assert) {
// for retro-compatibility reasons, the pivot view still handles
// '__count__' measure.