[FIX] base_import : show meaningful error message on import fail

Issue :
When you try to import a big file it will display a blank error.

Steps to reproduce the error :
1-install inventory and e-commerce
2-go to products and import records
3-upload the file attached the ticket

Reason :
Before, there was a type included in the `reason` but now
it seems that the error has no type neither a message.

Fix:
I tried to just output a general error.

opw-3410954

closes odoo/odoo#133950

X-original-commit: 95cc5c84c3b4529cd269cf278fd4ab289f28685f
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Signed-off-by: Mahdi Cheikh Rouhou (macr) <macr@odoo.com>
This commit is contained in:
Mahdi Cheikh Rouhou (macr)
2023-09-01 15:09:58 +00:00
parent 8faef71242
commit f1e563f6b2
+2 -20
View File
@@ -239,27 +239,9 @@ export class BaseImportModel {
const error = await this._executeImportStep(isTest, importRes);
if (error) {
let message;
const errorData = error.data || {};
if (errorData.type === "xhrerror") {
const xhr = errorData.objects[0];
switch (xhr.status) {
case 504: // gateway timeout
message = _t(
"Import timed out. Please retry. If you still encounter this issue, the file may be too big for the system's configuration, try to split it (import less records per file)."
);
break;
default:
message = _t(
"An unknown issue occurred during import (possibly lost connection, data limit exceeded or memory limits exceeded). Please retry in case the issue is transient. If the issue still occurs, try to split the file rather than import it at once."
);
}
} else {
message =
(errorData.arguments &&
(errorData.arguments[1] || errorData.arguments[0])) ||
error.message;
}
const message = errorData.arguments && (errorData.arguments[1] || errorData.arguments[0])
|| _t("An unknown issue occurred during import (possibly lost connection, data limit exceeded or memory limits exceeded). Please retry in case the issue is transient. If the issue still occurs, try to split the file rather than import it at once.");
if (error.message) {
this._addMessage("danger", [error.message, message]);