From ed2a77e50e94d957caca6dea309d84c55908cf93 Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Wed, 12 Jul 2017 09:45:46 +0200 Subject: [FIX] web: Fix FieldRadio's o_horizontal/vertical (#18163) --- .../static/tests/fields/relational_fields_tests.js | 34 +++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'addons/web/static/tests/fields/relational_fields_tests.js') diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index d4d3a6307f9..171b3e1f787 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -30,6 +30,7 @@ QUnit.module('relational_fields', { type: "selection", selection: [['red', "Red"], ['black', "Black"]], default: 'red', + string: "Color", }, date: {string: "Some Date", type: "date"}, datetime: {string: "Datetime Field", type: 'datetime'}, @@ -1472,11 +1473,11 @@ QUnit.module('relational_fields', { }, true); assert.strictEqual(form.$('td.o_data_cell:not(.o_handle_cell)').text(), "My little Foo Valueblipyop", - "should have the 3 rows in the correct order") + "should have the 3 rows in the correct order"); form.$buttons.find('.o_form_button_edit').click(); assert.strictEqual(form.$('td.o_data_cell:not(.o_handle_cell)').text(), "My little Foo Valueblipyop", - "should still have the 3 rows in the correct order") + "should still have the 3 rows in the correct order"); // Drag and drop the fourth line in second position testUtils.dragAndDrop( @@ -1489,11 +1490,11 @@ QUnit.module('relational_fields', { "sequences values should be incremental starting from the previous minimum one"); assert.strictEqual(form.$('td.o_data_cell:not(.o_handle_cell)').text(), "blipMy little Foo Valueyop", - "should have the 3 rows in the new order") + "should have the 3 rows in the new order"); form.$buttons.find('.o_form_button_save').click(); assert.strictEqual(form.$('td.o_data_cell:not(.o_handle_cell)').text(), "blipMy little Foo Valueyop", - "should still have the 3 rows in the new order") + "should still have the 3 rows in the new order"); form.destroy(); }); @@ -6412,6 +6413,31 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('fieldradio widget has o_horizontal or o_vertical class', function (assert) { + assert.expect(2); + + this.data.partner.fields.color2 = this.data.partner.fields.color; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '' + + '' + + '' + + '' + + '
', + }); + + var btn1 = form.$('div.o_field_radio.o_vertical'); + var btn2 = form.$('div.o_field_radio.o_horizontal'); + + assert.strictEqual(btn1.length, 1, "should have o_vertical class"); + assert.strictEqual(btn2.length, 1, "should have o_horizontal class"); + form.destroy(); + }); + QUnit.test('fieldradio widget with numerical keys encoded as strings', function (assert) { assert.expect(5); -- cgit v1.2.3 From f2c7e44efe4e2bcdc9c77c66dbd56b8b4cc397b2 Mon Sep 17 00:00:00 2001 From: Khoi Nguyen Date: Thu, 13 Jul 2017 17:40:35 +0200 Subject: [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. --- .../static/tests/fields/relational_fields_tests.js | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'addons/web/static/tests/fields/relational_fields_tests.js') 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: '
' + + '' + + '' + + '', + archs: { + 'partner,false,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(); -- cgit v1.2.3