Skip to Content
Menu
This question has been flagged
2 Replies
4904 Views

Hi there,


Does anybody know a clean way to create one PDF report from two QWeb reports in Odoo?


I'd like to combine a QWeb report from the model "sale.order" and one from "account.move" to generate one PDF from two QWeb reports and two models. My idea was to create a custom QWeb report for the "sale.order" part and then doing a t-call in QWeb to call a second report but this does not seem to work. Here's the code snippet:

<template id="report_delivery_note_document">
    <t t-call="sale_order_endpoint.external_layout">
        <t t-set="doc" t-value="doc.with_context(lang=lang)"/>
        <div class="page">
            <p>Loads of QWeb code here</p>
        </div>
        <t t-if="doc.invoice_ids">
            <t t-set="o" t-value="doc.invoice_ids[0]"/>
            <t t-call="account.report_invoice_document"/>
        </t>
     </t>
</template>

However this method has two issues (which already tell me this is not a good way or idea).
Odoo prevents doing this kind of behaviour with https://github.com/odoo/odoo/blob/5e85ee521edb70d4d2c7cdbf59c29794a8cd98b9/odoo/addons/base/models/ir_actions_report.py#L779-L781 and if you'd even override this so it is allowed (which would modify the core and is not a good idea) then the invoice PDF is injected twice too.

Does anybody have a good solution for this? In short I need the default invoice PDF to be inserted/added into my custom QWeb report.


Regards,
Yenthe

Avatar
Discard
Best Answer

Hi Yenthe the below snippet worked fine
Hope this helps 

Avatar
Discard

<template id="report_saleorder">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="sale.report_saleorder_document" t-lang="doc.partner_id.lang"/>
</t>
<t t-call="account.report_invoice_odinvoice">
<t t-set="docs" t-value="docs.invoice_ids[0]"/>
</t>
</t>
</template>

Best Answer

Hey , see if this help you in someway

https://www.odoo.com/forum/help-1/how-to-generate-a-single-pdf-of-multiple-reports-of-the-same-template-133486

Avatar
Discard
Related Posts Replies Views Activity
0
May 24
960
2
May 24
2331
3
Feb 24
2037
2
Nov 22
4885
0
Apr 24
919