[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.
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user