Attachment - HEIC Convert
iPhone and iPad photos arrive as HEIC/HEIF files that browsers and most tools cannot display. This module converts them to PNG automatically, the moment they are uploaded to Odoo.
Works everywhere attachments are created
Chatter uploads, incoming e-mail attachments, expense receipts, document uploads - every ir.attachment created with a .heic or .heif filename is converted on the fly. Both classic base64 uploads and the raw binary upload flows used by Odoo 19 are supported.
What you get
- Automatic conversion on upload - HEIC/HEIF images become PNG with no user action.
- Filename preserved - IMG_1234.heic becomes IMG_1234.png, and the mimetype is set correctly.
- Case-insensitive - .HEIC, .heic, .HeIf all convert.
- Manual actions - convert an existing attachment to PNG, or wrap an image into a PDF, directly from the attachment form.
- Fails safe - if a file cannot be decoded, the original attachment is stored unchanged and the error is logged.
Technical note
The conversion uses the Python library pyheif, which must be available on the server (pip install pyheif). On Odoo.sh, add it to your requirements.txt.
| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Lines of code | 151 |
| Technical Name |
attachment_heic_convert |
| License | OPL-1 |
| Website | https://www.rlsd.dk/ |
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module
Issue with HEIC auto-conversion in Odoo 19 Community — uploaded attachments are not converted
Hello,
We purchased/installed your module Attachment - HEIC convert for Odoo 19 Community Edition.
The module can now be installed successfully after installing the required Python dependency pyheif. We have also restarted Odoo, and Odoo can import pyheif correctly under the Odoo system user.
We verified this with:
The result is:
However, after the module is installed and Odoo is restarted, HEIC images uploaded as attachments are still not automatically converted. For example, when a user uploads an invoice/receipt photo taken with an iPhone in .heic format, Odoo still stores it as a HEIC file, and it cannot be previewed in Odoo like JPG/PNG images.
We checked the Odoo log during the upload. The module seems to be triggered:
So the module is loaded and the ir.attachment.create() method appears to be reached. But the file is still not converted.
After checking the module code, we found that the conversion logic seems to only process the datas field:
But in Odoo 19, some attachment upload flows appear to use the raw field instead of datas. In that case, the module detects the .heic filename, but the conversion is skipped because vals.get('datas') is empty.
The code also references raw, but it looks like it is only removed from the debug log output, not used for conversion:
Could you please check and update the module to support Odoo 19 attachment uploads where the uploaded file content is provided through raw instead of datas?
Ideally, the module should support both cases:
It would also be helpful if the filename extension check is case-insensitive, because iPhone photos may be uploaded as .HEIC, .heic, .HEIF, or .heif.
Expected behavior:
Current behavior:
Could you please provide a fixed version for Odoo 19, or let us know the recommended patch?
Thank you.
Issue with HEIC auto-conversion in Odoo 19 Community — uploaded attachments are not converted
Hi Jason,
Thank you for the report on attachment_heic_convert – you are right, and we have just released version 19.0.1.0.3 with a fix.
What happened: in Odoo 19, several upload flows (including the chatter and the new file upload paths) pass the file content to ir.attachment in the raw field (bytes) instead of datas (base64). The module only looked at datas, so those HEIC uploads skipped conversion entirely.
What the fix does:
The update is available from the Odoo Apps store now – please upgrade the module and let me know if any HEIC upload still comes through unconverted.
Regards, Mads
There are no comments yet!