From f1e563f6b27df0579e36d2aa83c0e08d7c11674d Mon Sep 17 00:00:00 2001 From: "Mahdi Cheikh Rouhou (macr)" Date: Wed, 12 Jul 2023 11:43:01 +0000 Subject: [PATCH] [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) Signed-off-by: Mahdi Cheikh Rouhou (macr) --- addons/base_import/static/src/import_model.js | 22 ++----------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/addons/base_import/static/src/import_model.js b/addons/base_import/static/src/import_model.js index 863c74f6b11..fe84c84899d 100644 --- a/addons/base_import/static/src/import_model.js +++ b/addons/base_import/static/src/import_model.js @@ -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]);