[FIX] web, project: consider context pivot_row_groupby
Fixing missed 'pivot_row_groupby' assigned to groupedBy in pivot_model.js in
Load function (Already done in reload function), which was missed in commit
42f22a2.
Added qunit test case for testing correct value.
Apply pivot_row_groupby on user in project
task-54027
This commit is contained in:
committed by
Romain Derie
parent
850bd33682
commit
c8a833cc10
@@ -63,6 +63,7 @@
|
||||
<field name="res_model">project.task</field>
|
||||
<field name="view_mode">kanban,tree,form,calendar,pivot,graph,activity</field>
|
||||
<field name="context">{
|
||||
'pivot_row_groupby': ['user_id'],
|
||||
'search_default_project_id': [active_id],
|
||||
'default_project_id': active_id,
|
||||
}</field>
|
||||
|
||||
@@ -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: {},
|
||||
|
||||
@@ -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: '<pivot>' +
|
||||
'<field name="customer" type="col"/>' +
|
||||
'<field name="date" interval="day" type="row"/>' +
|
||||
'</pivot>',
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user