-1

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>
Evan rianto
  • 19
  • 1
  • 7

1 Answers1

0

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.

  • Sorry for the late reply, this is one of my answer yes, but I really need the part where odoo convert their report into a pdf object too in version 14.0. I tried converting them using get_pdf and render_qweb_pdf so I can use your solution to finish it up, but it seems those functions is not available in odoo 14.0 – Evan rianto May 17 '21 at 01:20
  • I think It's easier to use controllers: Check this example in stock module: [stock/controllers/main.py#L25](https://github.com/odoo/odoo/blob/14.0/addons/stock/controllers/main.py#L25) Check also how they implement it in the view: [stock_traceability_report_data.xml#L7](https://github.com/odoo/odoo/blob/14.0/addons/stock/data/stock_traceability_report_data.xml#L7) – Rachid Al assir May 19 '21 at 00:52
  • Thanks, will check this later. Currently I'm skipping this issue first while working for other custom module. Much appreciated for the effort :) – Evan rianto May 20 '21 at 02:54