diff --git a/addons/web_editor/i18n/web_editor.pot b/addons/web_editor/i18n/web_editor.pot index c9e6e8210c0..bd342dbd46d 100644 --- a/addons/web_editor/i18n/web_editor.pot +++ b/addons/web_editor/i18n/web_editor.pot @@ -871,6 +871,12 @@ msgstr "" msgid "Could not install module %s" msgstr "" +#. module: web_editor +#. odoo-javascript +#: code:addons/web_editor/static/src/components/upload_progress_toast/upload_service.js:0 +#, python-format +msgid "Could not load the file \"%s\"." + #. module: web_editor #: model_terms:ir.ui.view,arch_db:web_editor.snippet_options_background_options msgid "Cover" diff --git a/addons/web_editor/static/src/components/upload_progress_toast/upload_service.js b/addons/web_editor/static/src/components/upload_progress_toast/upload_service.js index 4baa4824ee9..a81d3db3eac 100644 --- a/addons/web_editor/static/src/components/upload_progress_toast/upload_service.js +++ b/addons/web_editor/static/src/components/upload_progress_toast/upload_service.js @@ -2,9 +2,11 @@ import { registry } from '@web/core/registry'; import { UploadProgressToast } from './upload_progress_toast'; +import { _t } from "@web/core/l10n/translation"; import { checkFileSize } from "@web/core/utils/files"; import { humanNumber } from "@web/core/utils/numbers"; import { getDataURLFromFile } from "@web/core/utils/urls"; +import { sprintf } from "@web/core/utils/strings"; import { reactive } from "@odoo/owl"; export const AUTOCLOSE_DELAY = 3000; @@ -94,7 +96,20 @@ export const uploadService = { // limited by bandwidth. for (const sortedFile of sortedFiles) { const file = progressToast.files[sortedFile.progressToastId]; - const dataURL = await getDataURLFromFile(sortedFile); + let dataURL; + try { + dataURL = await getDataURLFromFile(sortedFile); + } catch { + deleteFile(file.id); + env.services.notification.add( + sprintf( + _t('Could not load the file "%s".'), + sortedFile.name + ), + { type: 'danger' } + ); + continue + } try { const xhr = new XMLHttpRequest(); xhr.upload.addEventListener('progress', ev => {