1

Hi all i am trying to change the file name of pdf print. I tried below two methods.

<report
            id="daily_invoice_report_print_menu"
            model="account.move"
            string="Invoice Print 12334"
            report_type="qweb-pdf"
            name="daily_report.daily_invoice_report_template"
            file="daily_report.daily_invoice_report_template"
            print_report_name = "(('Sales Invoice '+ object.name or 'Print').replace('/','')+'.pdf')"
    menu="False"/>

    <record id="daily_invoice_report_print_menu" model="ir.actions.report">
        <field name="name">Invoice Print 12334</field>
        <field name="model">daily.transaction.report</field>
        <field name="report_type">qweb-pdf</field>
        <field name="report_name">daily_report.daily_invoice_report_template</field>
        <field name="print_report_name">'(object.name+'.pdf')'</field>

    </record>

but still showing the file name as Invoice Print 1234

How can I solve this?

KbiR
  • 4,047
  • 6
  • 37
  • 103

1 Answers1

0

Yes Odoo uses the field print_report_name to change the name of the printed file, but this only possibly only for one record at a time, so if you select multiple records odoo will ignore this as you can see here:

if docids:
       ids = [int(x) for x in docids.split(",")]
       obj = request.env[report.model].browse(ids)
       if report.print_report_name and not len(obj) > 1:
          report_name = safe_eval(report.print_report_name, {'object': obj, 'time': time})
          filename = "%s.%s" % (report_name, extension)
Charif DZ
  • 14,415
  • 3
  • 21
  • 40
  • Charif DZ thanks to the reply. but I didn't understand completely. How can I change the value of print name? in the above code snippet also considering the print_report_name, right? – KbiR May 19 '22 at 11:17
  • What do you mean? when you select only one record and print it the file name is not generated correctly? – Charif DZ May 20 '22 at 00:09
  • Not that, actually i am trying to print the report from a wizard, in that wizard I can choose one customer. i need that customer name as a file name, this is what I need. Is it possible? – KbiR May 25 '22 at 04:18