summaryrefslogtreecommitdiff
path: root/addons/web
diff options
context:
space:
mode:
authorMathieu Duckerts-Antoine <dam@odoo.com>2020-08-11 15:16:32 +0000
committerMathieu Duckerts-Antoine <dam@odoo.com>2020-08-14 07:52:49 +0000
commit3da3ae11783c9ed6bc0634e07089f62ad05c75cb (patch)
treee1a5202253b17349ba30a50b38fb3ef7838584fa /addons/web
parenta137f22363ff538ab86f50d15851730af1b8ed76 (diff)
[FIX] web: pivot: avoid to toggle invalid measure
Before this commit, click on the divider in the menu 'Measures' of the pivot control panel would cause a crash. The present commit fixes that situation. We also bring another small correction: the menu won't close if one clicks on the measure list but not exactly on a menu item or the divider. closes odoo/odoo#55902 X-original-commit: aad9f3fd7499ef8b660cc25fea840a34d70f75a6 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Signed-off-by: Mathieu Duckerts-Antoine <Polymorphe57@users.noreply.github.com> Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Diffstat (limited to 'addons/web')
-rw-r--r--addons/web/static/src/js/views/pivot/pivot_controller.js2
-rw-r--r--addons/web/static/tests/views/pivot_tests.js26
2 files changed, 27 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/pivot/pivot_controller.js b/addons/web/static/src/js/views/pivot/pivot_controller.js
index 723d52aa25c..1138778156a 100644
--- a/addons/web/static/src/js/views/pivot/pivot_controller.js
+++ b/addons/web/static/src/js/views/pivot/pivot_controller.js
@@ -173,7 +173,7 @@ odoo.define('web.PivotController', function (require) {
if (ev.target.closest('.o_pivot_measures_list')) {
ev.preventDefault();
ev.stopPropagation();
- const field = $target.data('field');
+ const field = ev.target.dataset.field;
if (field) {
this.update({ measure: field });
}
diff --git a/addons/web/static/tests/views/pivot_tests.js b/addons/web/static/tests/views/pivot_tests.js
index 6fd8aaf4e92..ebcd2b69902 100644
--- a/addons/web/static/tests/views/pivot_tests.js
+++ b/addons/web/static/tests/views/pivot_tests.js
@@ -2333,6 +2333,32 @@ QUnit.module('Views', {
pivot.destroy();
});
+ QUnit.test('Click on the measure list but not on a menu item', async function (assert) {
+ assert.expect(2);
+
+ const pivot = await createView({
+ View: PivotView,
+ model: "partner",
+ data: this.data,
+ arch: `<pivot/>`,
+ });
+
+ // open the "Measures" menu
+ await testUtils.dom.click(pivot.el.querySelector('.o_cp_buttons button'));
+
+ // click on the divider in the "Measures" menu does not crash
+ await testUtils.dom.click(pivot.el.querySelector('.o_pivot_measures_list .dropdown-divider'));
+ // the menu should still be open
+ assert.isVisible(pivot.el.querySelector('.o_pivot_measures_list'));
+
+ // click on the measure list but not on a menu item or the separator
+ await testUtils.dom.click(pivot.el.querySelector('.o_pivot_measures_list'));
+ // the menu should still be open
+ assert.isVisible(pivot.el.querySelector('.o_pivot_measures_list'));
+
+ pivot.destroy();
+ });
+
QUnit.test('Navigation list view for a group and back with breadcrumbs', async function (assert) {
assert.expect(16);
// create an action manager to test the interactions with the search view