'How to generate multiple odoo qweb report (PDF Files) in a zip format?

For now I can use Odoo for single record report, but when I use multiple files, all the reports do not come in multiple PDF but in one PDF file. So, is there any way to get Odoo generated report as object, so I can collect them and compressed them in a zip format ? I haven't try anything yet because I never see any answer in other places as well.

This is my report code

<record id="action_report_1721A1" model="ir.actions.report">
            <field name="name">Generate PDF</field>
            <field name="model">wgs.form.1721.a1.list</field>
            <field name="report_type">qweb-pdf</field>
            <field name="report_name">wgs_perhitungan_form_1721_a1.report_1721A1</field>
            <field name="report_file">wgs_perhitungan_form_1721_a1.report_1721A1</field>
            <field name="print_report_name">'BUKTI POTONG PAJAK - {}  - TAHUN  {}'.format(object.employee_id.name, object.tahun)</field>
            <field name="paperformat_id" ref="wgs_perhitungan_form_1721_a1.paperformat_1721A1"/>
        </record>


Solution 1:[1]

Use zipfile and add each pdf file to it:

Example:

    temp = tempfile.mktemp(suffix='.zip')
    with zipfile.ZipFile(temp, 'w') as zfile:
         zfile.writestr(filename,your_buffer)

Also your_buffer can be an str or bytes.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1