Stéphan Sainléger fb7ff241f5 [FIX] hr_expense_report_merge_attachment: handle HEIC images uploaded as JPEG
Some iPhone users upload HEIC files with a ``.jpg`` extension. Odoo stores
the file as-is, but the mimetype is detected as ``image/...``, so the code
enters the image processing branch. ``reportlab``'s ``ImageReader`` relies
on ``PIL.Image.open()`` which cannot identify HEIC files without an explicit
plugin, causing a ``PIL.UnidentifiedImageError`` and a 500 error on report
download.

Fix by:
- Registering the ``pillow-heif`` opener at module load time (optional
  dependency, silently ignored if not installed) so that Pillow can decode
  HEIC/HEIF images.
- Converting any image to JPEG in memory via Pillow before passing it to
  ``ImageReader``, bypassing ``reportlab``'s own format detection entirely.
- Wrapping the image block in a ``try/except`` to gracefully skip
  attachments that cannot be decoded, consistent with the existing PDF
  error handling.
2026-05-15 13:36:43 +02:00
2022-06-22 14:13:39 +02:00
Description
No description provided
GPL-3.0 1 MiB
Languages
Python 100%