summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2021-01-06 08:27:57 +0000
committerAaron Bohy <aab@odoo.com>2021-01-06 08:36:15 +0000
commit6be8997807e4fbfeeefe273a335d9182490d0ac5 (patch)
tree4bbc9e825d3b55df9de5273654c10a81d264fe9e
parent061190123dc21001aaff6b19cf9a417b390a576a (diff)
[FIX] web: editable list: can unselect row
Since commit [1], it is no longer possible to unselect a row in a one2many editable list if there is an html field in the form view. The reason is that there is a '.modal' element (several actually) in the DOM of the html field. This element is considered as an opened dialog by the list renderer, which is wrong. This commit refines the selector that determines whether there is an opened dialog or not. [1] 7d04ec7cca4f355295a06c1ce6f112b6cc533c87 closes odoo/odoo#64127 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
-rw-r--r--addons/web/static/src/js/views/list/list_editable_renderer.js2
-rw-r--r--addons/web/static/tests/views/list_tests.js32
2 files changed, 33 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/list/list_editable_renderer.js b/addons/web/static/src/js/views/list/list_editable_renderer.js
index 2122e00ed0c..a3c47684991 100644
--- a/addons/web/static/src/js/views/list/list_editable_renderer.js
+++ b/addons/web/static/src/js/views/list/list_editable_renderer.js
@@ -1817,7 +1817,7 @@ ListRenderer.include({
// ignore clicks if there is a modal, except if the list is in the last
// (active) modal
- var $modal = $('.modal:last');
+ var $modal = $('body > .modal:last');
if ($modal.length) {
var $listModal = this.$el.closest('.modal');
if ($modal.prop('id') !== $listModal.prop('id')) {
diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js
index 8c0348c7e5c..6e142dff2ff 100644
--- a/addons/web/static/tests/views/list_tests.js
+++ b/addons/web/static/tests/views/list_tests.js
@@ -8245,6 +8245,38 @@ QUnit.module('Views', {
form.destroy();
});
+ QUnit.test('editable list alongside html field: click out to unselect the row', async function (assert) {
+ assert.expect(5);
+
+ const form = await createView({
+ View: FormView,
+ model: 'foo',
+ data: this.data,
+ arch: `
+ <form>
+ <field name="text" widget="html"/>
+ <field name="o2m">
+ <tree editable="bottom">
+ <field name="display_name"/>
+ </tree>
+ </field>
+ </form>`,
+ });
+
+ assert.containsNone(form, '.o_data_row');
+
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add > a'));
+ assert.containsOnce(form, '.o_data_row');
+ assert.hasClass(form.$('.o_data_row'), 'o_selected_row');
+
+ // click outside to unselect the row
+ await testUtils.dom.click(document.body);
+ assert.containsOnce(form, '.o_data_row');
+ assert.doesNotHaveClass(form.$('.o_data_row'), 'o_selected_row');
+
+ form.destroy();
+ });
+
QUnit.test('list grouped by date:month', async function (assert) {
assert.expect(1);