Tuesday, June 11, 2024
1 change · saas-17.3
Enhancements to existing features
Invoice Send & Print now processes multiple invoice PDFs together instead of one at a time, greatly reducing wait times for bulk operations. This improves the user experience for teams handling batches of invoices, especially when downloading or printing 5 or more documents.
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 invalidations. 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 | odoo-167729 task-3695628