[FIX] mass_mailing: handle UnidentifiedImageError while convert image to url
Currently, a logger exception is generated when the user tries to upload any image as document in the mass mail. This is because an UnidentifiedImageError occurs when the user uploads an image file as a document and code [1] tries to open it with Image. This commit adds code that handles an UnidentifiedImageError, and it adds the message in the log for an invalid image file. [1] - https://github.com/odoo/odoo/blob/029b84f3c061f819bacb9a4818504cced4adeb1c/addons/mass_mailing/models/mailing.py#L1405 sentry-4311184876 closes odoo/odoo#159653 X-original-commit: e4b7ec191fc81ec806736758f273e20b6260bbeb Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com> Signed-off-by: ANSARI MAHAMADASIF (maan) <maan@odoo.com>
This commit is contained in:
@@ -1440,6 +1440,9 @@ class MassMailing(models.Model):
|
||||
)
|
||||
|
||||
return content
|
||||
except UnidentifiedImageError:
|
||||
_logger.warning('This file could not be decoded as an image file.', exc_info=True)
|
||||
raise
|
||||
except Exception as e:
|
||||
_logger.exception(e)
|
||||
raise ImportValidationError(_("Could not retrieve URL: %s", url)) from e
|
||||
|
||||
Reference in New Issue
Block a user