summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields
diff options
context:
space:
mode:
authorKhoi Nguyen <bng@odoo.com>2017-07-13 17:40:35 +0200
committerKhoi Nguyen <bng@odoo.com>2017-07-14 10:35:35 +0200
commitf2c7e44efe4e2bcdc9c77c66dbd56b8b4cc397b2 (patch)
tree8c96109442c3670873be528d051dd446c4c32f18 /addons/web/static/tests/fields
parenta562f5ced1c61d2ac3854a17d193beda4d64b5e1 (diff)
[FIX] web: no M2ODialog when pressing enter in a many2one
Before this revision, pressing ENTER when inside a many2one field triggers a 'focus out' event. In particular, if one creates a many2one record and uses the ENTER key to click "Create and Edit", two dialog windows appear: one to actually create the associated record, and a second to alert the user that they are creating an associated record. The latter appears every time the many2one field loses focus. This commit changes the 'key up' event for many2one fields to ensure that the ENTER key does not trigger a 'focus out' event.
Diffstat (limited to 'addons/web/static/tests/fields')
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js
index 171b3e1f787..aacbb744252 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -1141,6 +1141,52 @@ QUnit.module('relational_fields', {
});
});
+ QUnit.test('pressing ENTER on a \'no_quick_create\' many2one should not trigger M2ODialog', function (assert) {
+ var done = assert.async();
+ assert.expect(1);
+
+ var M2O_DELAY = relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY;
+ relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = 0;
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form>' +
+ '<field name="trululu" options="{\'no_quick_create\': True}"/>' +
+ '<field name="foo"/>' +
+ '</form>',
+ archs: {
+ 'partner,false,form': '<form string="Partners"><field name="display_name"/></form>',
+ },
+ });
+
+ var $input = form.$('.o_field_many2one input');
+ $input.val("Something that does not exist").trigger('input');
+ $('.ui-autocomplete .ui-menu-item a:contains(Create and)').trigger('mouseenter');
+ concurrency.delay(0).then(function() {
+ $input.trigger($.Event('keydown', {
+ which: $.ui.keyCode.ENTER,
+ keyCode: $.ui.keyCode.ENTER,
+ }));
+ $input.trigger($.Event('keypress', {
+ which: $.ui.keyCode.ENTER,
+ keyCode: $.ui.keyCode.ENTER,
+ }));
+ $input.trigger($.Event('keyup', {
+ which: $.ui.keyCode.ENTER,
+ keyCode: $.ui.keyCode.ENTER,
+ }));
+ concurrency.delay(0).then(function() {
+ $input.blur();
+ assert.strictEqual($('.modal').length, 1,
+ "should have one modal in body");
+ form.destroy();
+ done();
+ });
+ });
+ });
+
QUnit.test('many2one in editable list + onchange, with enter [REQUIRE FOCUS]', function (assert) {
assert.expect(6);
var done = assert.async();