[FIX] web: don't change page before saving

When we edit a list view and change page before the change has been
savec, the saving and page changing will be done concurrently thus
possibly causing an error if the page is changed before the saved is
finished: the save will try to modify the page that is no more
displayed.

In this change, the list view editable wait for the saving to be
finished before reloading its content.

note: for 9.0 up to saas-15

opw-1839149
closes #24471
This commit is contained in:
Nicolas Lempereur
2018-05-03 09:11:44 +02:00
parent 532b11ce41
commit f12daec1a1
2 changed files with 19 additions and 2 deletions
+8 -2
View File
@@ -352,7 +352,7 @@ var ListView = View.extend( /** @lends instance.web.ListView# */ {
} else if (self.page > max_page_index) {
self.page = 0;
}
self.reload_content();
self.reload_content_when_ready();
}).find('.oe_list_pager_state')
.click(function (e) {
e.stopPropagation();
@@ -370,7 +370,7 @@ var ListView = View.extend( /** @lends instance.web.ListView# */ {
var val = parseInt($select.val(), 10);
self._limit = (isNaN(val) ? null : val);
self.page = 0;
self.reload_content();
self.reload_content_when_ready();
}).blur(function() {
$(this).trigger('change');
})
@@ -542,6 +542,12 @@ var ListView = View.extend( /** @lends instance.web.ListView# */ {
});
return reloaded.promise();
}),
/**
* Proxy allowing override when reload_content can't be called directly
*/
reload_content_when_ready: function() {
return this.reload_content.apply(this, arguments);
},
reload: function () {
return this.reload_content();
},
@@ -401,6 +401,17 @@ ListView.include(/** @lends instance.web.ListView# */{
});
return cells;
},
/**
* Prevent reloading content while an ongoing save
*/
reload_content_when_ready: function() {
var self = this;
var self_super = this._super;
var original_arguments = arguments;
return this.saving_mutex.exec(function() {
return self_super.apply(self, original_arguments);
});
},
/**
* If currently editing a row, resizes all registered form fields based
* on the corresponding row cell