summaryrefslogtreecommitdiff
path: root/addons/web/static/tests
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2020-12-22 14:41:27 +0000
committerAaron Bohy <aab@odoo.com>2021-01-04 14:15:22 +0000
commit7d04ec7cca4f355295a06c1ce6f112b6cc533c87 (patch)
treeef347de78a8574a4fe25a43d67fc94d036949eb2 /addons/web/static/tests
parent592ee14d7fe81e7e5afd23f2bbbdac344eae6060 (diff)
[FIX] web: editable list: do not discard row on m2o blur
Let's assume an editable list with a many2one field. The user types something in the many2one and then clicks outside (mousedown, not mouseup, and thus click, yet). A dialog opens to ask the user if he wants to quickcreate a record. Before this commit, the dialog and the row disappeared as soon as he released the click, because the click was considered by the list renderer as an "external click", and the row was discarded (alongside the many2one it contained). Task 2411029 closes odoo/odoo#63697 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Diffstat (limited to 'addons/web/static/tests')
-rw-r--r--addons/web/static/tests/views/list_tests.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js
index 81e95ddfabc..64894f3095a 100644
--- a/addons/web/static/tests/views/list_tests.js
+++ b/addons/web/static/tests/views/list_tests.js
@@ -8175,6 +8175,52 @@ QUnit.module('Views', {
list.destroy();
});
+ QUnit.test('editable list with many2one: click out does not discard the row', async function (assert) {
+ // In this test, we simulate a long click by manually triggering a mousedown and later on
+ // mouseup and click events
+ assert.expect(5);
+
+ this.data.bar.fields.m2o = {string: "M2O field", type: "many2one", relation: "foo"};
+
+ const form = await createView({
+ View: FormView,
+ model: 'foo',
+ data: this.data,
+ arch: `
+ <form>
+ <field name="display_name"/>
+ <field name="o2m">
+ <tree editable="bottom">
+ <field name="m2o" required="1"/>
+ </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');
+
+ // focus and write something in the m2o
+ form.$('.o_field_many2one input').focus().val('abcdef').trigger('keyup');
+ await testUtils.nextTick();
+
+ // then simulate a mousedown outside
+ form.$('.o_field_widget[name="display_name"]').focus().trigger('mousedown');
+ await testUtils.nextTick();
+ assert.containsOnce(document.body, '.modal', "should ask confirmation to create a record");
+
+ // trigger the mouseup and the click
+ form.$('.o_field_widget[name="display_name"]').trigger('mouseup').trigger('click');
+ await testUtils.nextTick();
+
+ assert.containsOnce(document.body, '.modal', "modal should still be displayed");
+ assert.containsOnce(form, '.o_data_row', "the row should still be there");
+
+ form.destroy();
+ });
+
QUnit.test('list grouped by date:month', async function (assert) {
assert.expect(1);