[FIX] web: search in m2o displays lost connection notification
In the PR 104415, we add the possibility to abort the name_search rpcs which will be ignored. Unfortunately, we forgot that xhr.abort performs a reject which will be converted into an "XmlHttpRequestError abort" error. This error will cause a notification "Connection lost. Trying to reconnect...". Solution: We revert the modifications in the abort function and in the m2o we catch all the errors on the rpc name_search that we are going to abort because they have no more use. How to reproduce: - Go to a form view with a m2o field - Having a slow network or a lot of records in the m2o - Enter several char in the m2o search bar Before this commit: A notification "Connection lost. Trying to reconnect..." is displayed. After this commit: There is no notification. closes odoo/odoo#109500 X-original-commit: 7bff161ac5e916bf4d4eabe4f9ada9a147893cf2 Signed-off-by: Samuel Degueldre <sad@odoo.com>
This commit is contained in:
committed by
Samuel Degueldre
parent
d9b812d3f9
commit
2587f31912
@@ -97,17 +97,11 @@ function _genericJsonRpc (fct_name, params, settings, fct) {
|
||||
});
|
||||
|
||||
// FIXME: jsonp?
|
||||
/**
|
||||
* @param {Boolean} rejectError Returns an error if true. Allows you to cancel
|
||||
* ignored rpc's in order to unblock the ui and not display an error.
|
||||
*/
|
||||
promise.abort = function (rejectError = true) {
|
||||
if (rejectError) {
|
||||
rejection({
|
||||
message: "XmlHttpRequestError abort",
|
||||
event: $.Event('abort')
|
||||
});
|
||||
}
|
||||
promise.abort = function () {
|
||||
rejection({
|
||||
message: "XmlHttpRequestError abort",
|
||||
event: $.Event('abort')
|
||||
});
|
||||
|
||||
if (!shadow) {
|
||||
core.bus.trigger('rpc_response');
|
||||
|
||||
@@ -641,6 +641,10 @@ var FieldMany2One = AbstractField.extend({
|
||||
}
|
||||
|
||||
if (this.lastNameSearch) {
|
||||
this.lastNameSearch.catch((reason) => {
|
||||
// the last rpc name_search will be aborted, so we want to ignore its rejection
|
||||
reason.event.preventDefault();
|
||||
})
|
||||
this.lastNameSearch.abort(false)
|
||||
}
|
||||
this.lastNameSearch = this._rpc({
|
||||
|
||||
Reference in New Issue
Block a user