From b73518fe579f3902171969ce6ac7438bce64f925 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Sat, 12 Nov 2016 20:53:14 +0100 Subject: [PATCH] [FIX] web: do not cancel edition on o2m list when pressing Enter Rev. 3f7d350fe21d9e2afb35a9ce3e2652940e3f259d1 introduced auto-cancellation of the edit mode when the user clicks outside the edited line. The unfortunate downside was the auto-cancellation of the edit mode also when the user presses ENTER while the line is not valid. This is especially annoying when using barcode scanners to fill in values, as scanners usually send an ENTER keystroke at the end of the input sequence. When a many2one field is focused this event will often occur before the autocompletion popup has a chance to open. At that point the line is considered invalid, and the edition mode is cancelled! If no field is considered dirty yet on the line this simply drops the whole line, otherwise it will open a navigation confirmation popup. Both results equally prevent the use of barcode scanners. This patch makes sure the edit mode is only cancelled when the user indeed clicked outside the line, and not for other cases where save() is requested, such as an ENTER keystroke. --- addons/web/static/src/js/views/form_relational_widgets.js | 2 +- addons/web/static/src/js/views/list_view_editable.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/js/views/form_relational_widgets.js b/addons/web/static/src/js/views/form_relational_widgets.js index 61ffc70631a..4ceded791be 100644 --- a/addons/web/static/src/js/views/form_relational_widgets.js +++ b/addons/web/static/src/js/views/form_relational_widgets.js @@ -1217,7 +1217,7 @@ var One2ManyListView = X2ManyListView.extend({ this.dataset.x2m.internal_dataset_changed = false; var self = this; - return this.save_edition().done(function () { + return this.save_edition(true).done(function () { if (self._dataset_changed) { self.dataset.trigger('dataset_changed'); } diff --git a/addons/web/static/src/js/views/list_view_editable.js b/addons/web/static/src/js/views/list_view_editable.js index 507d933508b..5786f9365ee 100644 --- a/addons/web/static/src/js/views/list_view_editable.js +++ b/addons/web/static/src/js/views/list_view_editable.js @@ -439,7 +439,7 @@ ListView.include(/** @lends instance.web.ListView# */{ /** * @return {jQuery.Deferred} */ - save_edition: function () { + save_edition: function (cancel_onfail) { var self = this; return self.saving_mutex.exec(function() { if (!self.editor.is_editing()) { @@ -474,7 +474,9 @@ ListView.include(/** @lends instance.web.ListView# */{ return {created: created, record: record}; }); }, function() { - return self.cancel_edition(); + if (cancel_onfail) { + return self.cancel_edition(); + } }); }); });