summaryrefslogtreecommitdiff
path: root/addons/web/static/tests
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2020-07-29 12:41:01 +0000
committerNicolas Lempereur <nle@odoo.com>2020-08-14 12:31:50 +0000
commit7cf8f6f40e5769d2f22620ac425208c4ad9ae80b (patch)
tree17aad5a5f5159019ee57ea7743d8260554c0b5be /addons/web/static/tests
parent43769580f5c1b4f71f85474e335e0d46b8afc43c (diff)
[FIX] web: pivot non-persistant on null value
In pivot view, a cell data is determined by his row/column key which are the value chain of field values to get to that row/column. If you had a grouping with value in a cell and then close the grouping, you could somehow get the old value back wrongly on next grouping operations. This happened because: - the key was computed based on the value (eg. for relational field the record ID) but without the field name. - succeeding read_group only fill existing values. eg. If on pivot view we had a salesperson with same ID as product category, if we closed salesperson grouping then opened product category grouping, we could possibly get the cell value to the product category that has the same ID as the salesperson. With this changeset, we clear the cell data corresponding to a grouping that has been closed. Added test without the fix would fail by displaying data of a previous read_group that should have been cleared inbetween. opw-2262306 closes #55129 closes odoo/odoo#55936 X-original-commit: f1df73adca4955561814d4b8e90a62d7d50c1c33 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Diffstat (limited to 'addons/web/static/tests')
-rw-r--r--addons/web/static/tests/views/pivot_tests.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/addons/web/static/tests/views/pivot_tests.js b/addons/web/static/tests/views/pivot_tests.js
index ebcd2b69902..48e67e8641e 100644
--- a/addons/web/static/tests/views/pivot_tests.js
+++ b/addons/web/static/tests/views/pivot_tests.js
@@ -1511,6 +1511,37 @@ QUnit.module('Views', {
pivot.destroy();
});
+ QUnit.test('clear table cells data after closeGroup', async function (assert) {
+ assert.expect(2);
+
+ const pivot = await createView({
+ View: PivotView,
+ model: "partner",
+ data: this.data,
+ arch: '<pivot/>',
+ groupBy: ['product_id'],
+ });
+
+ await testUtils.dom.click(pivot.el.querySelector('thead .o_pivot_header_cell_closed'));
+ await testUtils.dom.click(pivot.el.querySelectorAll('.o_pivot_field_menu .dropdown-item[data-field="date"]')[0]);
+
+ // close and reopen row groupings after changing value
+ this.data.partner.records.find(r => r.product_id === 37).date = '2016-10-27';
+ await testUtils.dom.click(pivot.el.querySelector('tbody .o_pivot_header_cell_opened'));
+ await testUtils.dom.click(pivot.el.querySelector('tbody .o_pivot_header_cell_closed'));
+ await testUtils.dom.click(pivot.el.querySelector('.o_pivot_field_menu .dropdown-item[data-field="product_id"]'));
+ assert.strictEqual(pivot.el.querySelectorAll('.o_pivot_cell_value')[4].innerText, ''); // xphone December 2016
+
+ // invert axis, and reopen column groupings
+ await testUtils.dom.click(pivot.el.querySelector('.o_cp_buttons .o_pivot_flip_button'));
+ await testUtils.dom.click(pivot.el.querySelector('thead .o_pivot_header_cell_opened'));
+ await testUtils.dom.click(pivot.el.querySelector('thead .o_pivot_header_cell_closed'));
+ await testUtils.dom.click(pivot.el.querySelector('.o_pivot_field_menu .dropdown-item[data-field="product_id"]'));
+ assert.strictEqual(pivot.el.querySelectorAll('.o_pivot_cell_value')[3].innerText, ''); // December 2016 xphone
+
+ pivot.destroy();
+ });
+
QUnit.test('correctly uses pivot_ keys from the context (at reload)', async function (assert) {
assert.expect(8);