summaryrefslogtreecommitdiff
path: root/addons/web
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-10-31 16:29:07 +0100
committerChristophe Simonis <chs@odoo.com>2017-10-31 16:29:07 +0100
commit8f1e2044cd9dd0e3d5ab29f7527efdb0a9c7a582 (patch)
treeb531c2fbd3a85855c6691cb707435a3db89162e3 /addons/web
parentc8b2f5ca9ec0bbb5af06be8f8cf93122d08c41fe (diff)
parent810b6aa7600bad6bba4d0fc67f04ecf4975193d5 (diff)
[MERGE] forward port branch saas-16 up to 810b6aa7600
Diffstat (limited to 'addons/web')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js13
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js32
2 files changed, 40 insertions, 5 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index f2cacb3327f..ae3080b3b8e 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -534,14 +534,17 @@ var FieldMany2One = AbstractField.extend({
* start/end of the input element. Stops any navigation move event if the
* user is selecting text.
*
- * TODO this is a duplicate of InputField._onNavigationMove, maybe this
- * should be done in a mixin or, better, the m2o field should be an
- * InputField (but this requires some refactoring).
- *
* @private
* @param {OdooEvent} ev
*/
- _onNavigationMove: basicFields.InputField.prototype._onNavigationMove,
+ _onNavigationMove: function (ev) {
+ // TODO Maybe this should be done in a mixin or, better, the m2o field
+ // should be an InputField (but this requires some refactoring).
+ basicFields.InputField.prototype._onNavigationMove.apply(this, arguments);
+ if (this.mode === 'edit' && $(this.$input.autocomplete('widget')).is(':visible')) {
+ ev.stopPropagation();
+ }
+ },
/**
* @private
* @param {OdooEvent} event
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js
index f21db07f088..fe98eaaeab2 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -572,6 +572,38 @@ QUnit.module('relational_fields', {
form.destroy();
});
+ QUnit.test('many2one field and list navigation', function (assert) {
+ assert.expect(3);
+
+ var list = createView({
+ View: ListView,
+ model: 'partner',
+ data: this.data,
+ arch: '<tree editable="bottom"><field name="trululu"/></tree>',
+ });
+
+ // edit first input, to trigger autocomplete
+ list.$('.o_data_row .o_data_cell').first().click();
+ list.$('.o_data_cell input').val('').trigger('input');
+
+ // press keydown, to select first choice
+ list.$('.o_data_cell input').focus().trigger($.Event('keydown', {
+ which: $.ui.keyCode.DOWN,
+ keyCode: $.ui.keyCode.DOWN,
+ }));
+
+ // we now check that the dropdown is open (and that the focus did not go
+ // to the next line)
+ var $dropdown = list.$('.o_field_many2one input').autocomplete('widget');
+ assert.ok($dropdown.is(':visible'), "dropdown should be visible");
+ assert.ok(list.$('.o_data_row:eq(0)').hasClass('o_selected_row'),
+ 'first data row should still be selected');
+ assert.ok(!list.$('.o_data_row:eq(1)').hasClass('o_selected_row'),
+ 'second data row should not be selected');
+
+ list.destroy();
+ });
+
QUnit.test('standalone many2one field', function (assert) {
assert.expect(3);
var done = assert.async();