Tuesday, June 11, 2024
1 change · saas-17.3
Enhancements to existing features
Invoice Send & Print now generates PDFs in batches instead of one invoice at a time, reducing waiting times when processing multiple invoices. This makes bulk invoice downloads and sending much faster, especially for batches of 5 or more invoices.
Original PR description
Problem --------- When doing the Send & Print on one invoice, or when multiple invoices are selected and the "Download" option is ticked, the PDF generation of the invoices is made synchronously.…
Problem --------- When doing the Send & Print on one invoice, or when multiple invoices are selected and the "Download" option is ticked, the PDF generation of the invoices is made synchronously. Generating a simple invoice takes ~2 seconds. When you're doing the mass Send&Print for 10+ invoices, you can have your screen loading for >20seconds just to get 10+pages of PDF. Objective --------- Start digging into that part to see if optimisation can be done to reduce that loading time for UX improvements. Solution --------- Rather than calling wkhtmltopdf once per invoice, we allow the creation of all invoices' PDF together through one single call to the library. The PDF containing all the invoices will then be split and return as a dictionary. To do so we decoupled the `_render_qweb_pdf` function: - `_render_qweb_pdf` returns a aggregate of all the PDF - `_pre_render_qweb_pdf` returns the dictionary of all PDF split Furthermore, this commit batches some of the ORM calls; namely, attachments creation and cache invalidation. Results --------- | # Input data | Before PR | After PR | |:-------------:|:----------:|:---------:| | 1 | 3.3 s | 3.3 s | | 5 | 13.9 s | 4.4 s | | 10 | 27.5 s | 5.4 s | | 20 | 55.16 s | 8.4 s | enterprise-63706 task-3695628 --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr