How can i modify the "text file name" coming in print option

How can i modify the text file name coming in print option.
For example in the format <text_file_name>., where date needs to come up automatically given in the form view.
One of the example like Test2020-07-13, where Test is the text file name and date is 2020-07-13.

Any help on the above query will be highly grateful!!

You can extend Report.execute of your custom report and modify the last element of the result (the report name) which will be used by the client to construct the file name.

1 Like

Is there any module in tryton where it is used to check for the code reference.

I think that there isn’t any example in the code, but you have to do something like this:

@classmethod
def execute(cls, ids, data):
    res = super(Report, cls).execute(ids, data)
    # convert the res to a list because it is a tuple and we need to modify it
    aux = list(res)
    aux[-1] = 'new report name'
    return tuple(aux)

Anyway, I think that would be better if the file name could be set through the data argument when calling super.

@ced any recommedations for the same??
I am not getting any clue for the same.

@oscarQ I tried the code but still unable to understand how will it work, I am still seeing the same name of the text file as given in report_name in xml file.

There is an example with the InvoiceReport: modules/account_invoice: 7383144676cd invoice.py

1 Like

On installing the module account invoice this also contains the simple name of the report which is “invoice” `

<record model="ir.action.report" id="report_invoice">
        <field name="name">Invoice</field>
        <field name="model">account.invoice</field>
        <field name="report_name">account.invoice</field>
        <field name="report">account_invoice/invoice.fodt</field>
        <field name="single" eval="True"/>
    </record>
    <record model="ir.action.keyword" id="report_invoice_keyword">
        <field name="keyword">form_print</field>
        <field name="model">account.invoice,-1</field>
        <field name="action" ref="report_invoice"/>
    </record>`

But I want to change the name of the report. I donot want the report name to be just a simple text like Invoice rather i want it to be a Invoice and invoice.number.
Ex:- Invoice12345 here Invoice12345 is the name of the report and 12345 should be the invoice.number it should come as the its value given in the form view by the user.

This is what is implemented by default on the invoice report.
The linkt to the source code has been already posted on last topic by Cedric.

1 Like