M.E.
M.E.

Reputation: 5495

Change pdf file name in report definition Odoo 10

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

Upvotes: 2

Views: 3076

Answers (3)

ruuter
ruuter

Reputation: 2533

The field you are looking for is print_report_name. Help text for the field says:

This is the filename of the report going to download. Keep empty to not change the report filename. You can use a python expression with the object and time variables.

The field is defined on ir.actions.report.xml. See the definition here.

Simplest way to use it is via web UI: Settings -> Reports -> Reports
Choose the desired report and fill in the Printed Report Name field.

For example I have something like this there:
'ABC_' + ('Sale_Order' if object.state == 'sale' else 'Quotation') + '_' + object.name + '.pdf' which will result to: ABC_Sale_Order_SO0001.pdf

The expression is evaluated here, if you'd like to see where the magic happens ;)

Upvotes: 6

KbiR
KbiR

Reputation: 4174

Use attribute string.

 <report id="action_report_followup"
   model="account_followup.followup"
    string="Follow-up Report"
    report_type="qweb-pdf"
    name="payment_followup.report_followup"
    file="payment_followup.report_followup"
     menu="True"/>

Hope it will help you.

Upvotes: -1

Keval Mehta
Keval Mehta

Reputation: 664

For giving your custom pdf file name use field "report_name".

For more information and any help related qweb report you can refer following link:

https://www.odoo.com/documentation/10.0/reference/reports.html

Upvotes: 1

Related Questions