This question has been flagged
4 Replies
23337 Views

Given this report definition, how can I change the file name used in the PDF so it uses names such as "SO-001.pdf".

<report
        id = "report_custom_sale_order"
        string = "Quotation / Order"
        model = "sale.order"
        report_type = "qweb-pdf"
        file = "custom_saleorder.report_saleorder"
        name = "custom_saleorder.report_saleorder"
        paperformat = "custom_saleorder.paperformat_a4"
/>

Odoo 10.

Thanks

Avatar
Discard
Best Answer

Add 'print_report_name' in your custom module

<report
        id = "report_custom_sale_order"
        string = "Quotation / Order"
        model = "sale.order"
        report_type = "qweb-pdf"
        file = "custom_saleorder.report_saleorder"
        name = "custom_saleorder.report_saleorder"
        paperformat = "custom_saleorder.paperformat_a4"
        print_report_name = "(object.name+'.pdf')"
/>
Avatar
Discard

then I add print_report_name = ... it fails with:

AssertionError: Element odoo has extra content: data, line 3

without this works fine

for avoiding AssertionError: Element odoo has extra content: data, line 3.

need to inehrit same report like this:

<record model="ir.actions.report.xml" id="sale.report_sale_order">

<field name="print_report_name">(object.name+'.pdf')</field>

</record>

Best Answer

Hi,

you  can do it like this, activate the developer mode, then go to Settings -> Technical ->reports ->reports, select the report of the sales, ie , report named Quotation / Order. Then open the report and add "((object.name or '').replace('/','')+'.pdf')" this to field Printed Report Name. Then go to sales and print the report

Thanks

Avatar
Discard
Author

Thanks, but I want to do it programmatically so I can easily setup the same in other databases. It is a custom module.