Tuesday, November 29, 2022
1 change · master
Resolved issues and error corrections
The invoice send and print wizard now avoids creating duplicate PDF files and duplicate attachments when opened or used. This reduces clutter on invoices and improves performance by preventing unnecessary document generation.
Original PR description
This commit revamps the 'send & print' wizard. Previously when opening the wizard, 2 PDF were rendered, 1 was added to the move. When clicking "Send & Print" in the wizard, another PDF was added to…
This commit revamps the 'send & print' wizard.
Previously when opening the wizard, 2 PDF were rendered, 1 was added to the move.
When clicking "Send & Print" in the wizard, another PDF was added to the move,
and the other attachments were also duplicated on the move.
Now:
We avoid creating a PDF on the move when opening the wizard, using a context key.
In addition, when opening the wizard, the move's attachments
are *linked* to the wizard rather than recreated, s.t. when closing the
wizard, the attachments (except the PDF) are not duplicated on the move.
When using the context key, a weird bug occured (template was
not loaded directly, empty wizard, as reported in
3ae25d6).
Changing account.invoice.send from delegation inheritance to
classical inheritance solved it.
It also prevents us from generating 2 times a PDF when opening
the wizard (it was the case previously).
If we choose the option 'Print' in the wizard, we will still have a duplicated
PDF if the filename in the email template is different from:
{{ (object.name or '').replace('/','_') }}{{ object.state == 'draft' and '_draft' or '' }}
Indeed, the ir.actions.reports triggers the _render_qweb_pdf, which by default
regenerate a new PDF and creates a new attachment on the move if it doesn't already
exists (see retrieve_attachment in ir.actions.report).
task-???
Odoo PR: https://github.com/odoo/odoo/pull/96674