odoo/odoo#200945
Created by fw-bot
Statuses:
- legal/cla: Contributor License Agreement check
- ci/runbot: Odoo Test Suite
- ci/upgrade_enterprise: Test upgrades for enterprise master
- ci/template: Contact runbot team on discord for help.
- ci/style: Optional style check. Ignore it only if strictly necessary.
- ci/security: Required security check. Can only be ignored by security team.
- label
- odoo-dev:saas-18.1-16.0-opw-4486363-switch_main_attachment-mcou-421351-fw
- head
- de09142b79b601670c210f62cd5bcfaa38aa9620
- merged
- 7 months ago by Bugfix, Mathieu Coutant (mcou)
odoo/odoo | |
---|---|
16.0 | #196446 |
17.0 | #200243 |
saas-17.4 | #200427 |
18.0 | #200817 |
saas-18.1 | #200945 |
saas-18.2 | #200956 |
saas-18.3 | |
saas-18.4 | |
19.0 | |
master | #200995 |
[FW][FIX] mail: display arrows to switch to a valid attachment
Steps to reproduce:
- Create a new invoice
- Attach a ZIP file then a PDF file
- The file viewer shows but tries to preview the ZIP file
- Happens with all non-viewable files
Cause:
The ZIP file is put as main attachment and the method register_as_main_attachment
only change the main attachment (with force=False
) when there is no main attachment.
The behavior of the file viewer is problematic because we cannot switch between the attachments in the preview, so we cannot see the PDF. But if we add another PDF file (so one ZIP and 2 PDFs), we can switch but it will never show the ZIP again, only the two PDFs. This behavior is due to the next/previous arrows being displayed only if attachmentsInWebClientView
contains more than one item. But this list only contains viewable attachments (PDF or Images), and the next/previous arrows only take attachments from this list. As the arrows are changing the main attachment to change the displayed preview, it never comes back to the problematic ZIP file.
Solution:
Also display the arrows if the main attachment is not viewable and there is more than one attachment.
This way the user can return in the list of viewable attachments.
This is not an optimal because Odoo will still try to display the ZIP file, but it is a simple fix that works.
I tried restraining the main attachment field only to viewable files in this PR, but it seems to break things specially with OCR extraction and apparently it is sometimes wanted to have an XML as main attachment.