[FIX] web: get_file handles arbitrary AND serialized exceptions
Commit bcd4c90 was intendend to make get_file handle uncaught/unserialized exceptions
in the context of a http request
The drawback is that when get_file received a serialized exception (route: /report/download)
the JS modal was empty in that case
This commit handles both the cases
OPW 1848606
closes #24794
This commit is contained in:
@@ -232,12 +232,20 @@ function get_file(options) {
|
||||
if (options.error) {
|
||||
var body = this.contentDocument.body;
|
||||
var nodes = body.children.length === 0 ? body.childNodes : body.children;
|
||||
options.error({
|
||||
message: nodes.length > 1 ? nodes[1].textContent : '',
|
||||
data: {
|
||||
title: nodes.length > 0 ? nodes[0].textContent : '',
|
||||
},
|
||||
});
|
||||
var errorParams = {};
|
||||
|
||||
try { // Case of a serialized Odoo Exception: It is Json Parsable
|
||||
var node = nodes[1] || nodes[0];
|
||||
errorParams = JSON.parse(node.textContent);
|
||||
} catch (e) { // Arbitrary uncaught python side exception
|
||||
errorParams = {
|
||||
message: nodes.length > 1 ? nodes[1].textContent : '',
|
||||
data: {
|
||||
title: nodes.length > 0 ? nodes[0].textContent : '',
|
||||
}
|
||||
}
|
||||
}
|
||||
options.error(errorParams);
|
||||
}
|
||||
} finally {
|
||||
complete();
|
||||
|
||||
Reference in New Issue
Block a user