[FIX] web: pivot unload filter, reset, load another filter
On a pivot view with a default filter which has column and row groupbys Remove the filter Collapse all columns and rows Activate another Filter from favorite which has a column groupby at least Before this commit, the columns were not displayed in the DOM, though RPC's and internal data were actually correct This was because we considered the changes had been done "in place" taking the old tree to build the new one for the columns when really, we should have recomputed the column tree After this commit, the columns display the group we want OPW 1935155 closes odoo/odoo#31247
This commit is contained in:
@@ -277,8 +277,10 @@ var PivotModel = AbstractModel.extend({
|
||||
self._updateMainGroupBys(old_row, self.data.main_row);
|
||||
}
|
||||
|
||||
self._updateTree(old_col.root, self.data.main_col.root);
|
||||
self._updateMainGroupBys(old_col, self.data.main_col);
|
||||
if (!('pivot_column_groupby' in (params.context || {}))) {
|
||||
self._updateTree(old_col.root, self.data.main_col.root);
|
||||
self._updateMainGroupBys(old_col, self.data.main_col);
|
||||
}
|
||||
});
|
||||
},
|
||||
/**
|
||||
|
||||
@@ -899,6 +899,95 @@ QUnit.module('Views', {
|
||||
pivot.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('Unload Filter, reset display, load another filter', function (assert) {
|
||||
assert.expect(18);
|
||||
|
||||
var pivot = createView({
|
||||
View: PivotView,
|
||||
model: "partner",
|
||||
data: this.data,
|
||||
arch: '<pivot>' +
|
||||
'<field name="foo" type="measure"/>' +
|
||||
'</pivot>',
|
||||
viewOptions: {
|
||||
context: {
|
||||
pivot_measures: ['foo'],
|
||||
pivot_column_groupby: ['customer'],
|
||||
pivot_row_groupby: ['product_id'],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Check Columns
|
||||
assert.strictEqual(pivot.$('thead .o_pivot_header_cell_opened').length, 1,
|
||||
'The column should be grouped');
|
||||
assert.strictEqual(pivot.$('thead tr:contains("First")').length, 1,
|
||||
'There should be a column "First"');
|
||||
assert.strictEqual(pivot.$('thead tr:contains("Second")').length, 1,
|
||||
'There should be a column "Second"');
|
||||
|
||||
// Check Rows
|
||||
assert.strictEqual(pivot.$('tbody .o_pivot_header_cell_opened').length, 1,
|
||||
'The row should be grouped');
|
||||
assert.strictEqual(pivot.$('tbody tr:contains("xphone")').length, 1,
|
||||
'There should be a row "xphone"');
|
||||
assert.strictEqual(pivot.$('tbody tr:contains("xpad")').length, 1,
|
||||
'There should be a row "xpad"');
|
||||
|
||||
// Equivalent to unload the filter
|
||||
var reloadParams = {
|
||||
context: {},
|
||||
};
|
||||
pivot.reload(reloadParams);
|
||||
// collapse all headers
|
||||
pivot.$('.o_pivot_header_cell_opened').click();
|
||||
pivot.$('.o_pivot_header_cell_opened').click();
|
||||
|
||||
// Check Columns
|
||||
assert.strictEqual(pivot.$('thead .o_pivot_header_cell_closed').length, 1,
|
||||
'The column should not be grouped');
|
||||
assert.strictEqual(pivot.$('thead tr:contains("First")').length, 0,
|
||||
'There should not be a column "First"');
|
||||
assert.strictEqual(pivot.$('thead tr:contains("Second")').length, 0,
|
||||
'There should not be a column "Second"');
|
||||
|
||||
// Check Rows
|
||||
assert.strictEqual(pivot.$('tbody .o_pivot_header_cell_closed').length, 1,
|
||||
'The row should not be grouped');
|
||||
assert.strictEqual(pivot.$('tbody tr:contains("xphone")').length, 0,
|
||||
'There should not be a row "xphone"');
|
||||
assert.strictEqual(pivot.$('tbody tr:contains("xpad")').length, 0,
|
||||
'There should not be a row "xpad"');
|
||||
|
||||
// Equivalent to load another filter
|
||||
reloadParams = {
|
||||
context: {
|
||||
pivot_measures: ['foo'],
|
||||
pivot_column_groupby: ['customer'],
|
||||
pivot_row_groupby: ['product_id'],
|
||||
},
|
||||
};
|
||||
pivot.reload(reloadParams);
|
||||
|
||||
// Check Columns
|
||||
assert.strictEqual(pivot.$('thead .o_pivot_header_cell_opened').length, 1,
|
||||
'The column should be grouped');
|
||||
assert.strictEqual(pivot.$('thead tr:contains("First")').length, 1,
|
||||
'There should be a column "First"');
|
||||
assert.strictEqual(pivot.$('thead tr:contains("Second")').length, 1,
|
||||
'There should be a column "Second"');
|
||||
|
||||
// Check Rows
|
||||
assert.strictEqual(pivot.$('tbody .o_pivot_header_cell_opened').length, 1,
|
||||
'The row should be grouped');
|
||||
assert.strictEqual(pivot.$('tbody tr:contains("xphone")').length, 1,
|
||||
'There should be a row "xphone"');
|
||||
assert.strictEqual(pivot.$('tbody tr:contains("xpad")').length, 1,
|
||||
'There should be a row "xpad"');
|
||||
|
||||
pivot.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('correctly uses pivot_ keys from the context', function (assert) {
|
||||
assert.expect(7);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user