I’m using Odoo 17 and I added a custom button on the project form view that displays wizard view to recap some informations and then export them inside a PDF report. Everything works fine except one thing : I can’t change the name of the PDF. Here is my code :
report/ir_actions_report.xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="action_report_custom" model="ir.actions.report">
<field name="name">My Custom PDF</field>
<field name="model">report.custom_module.my_report</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">custom_module.my_report</field>
<field name="report_file">custom_module.my_report</field>
<field name="print_report_name">'the name of the file'</field>
<field name="binding_type">report</field>
</record>
</odoo>
report/custom_report.py
from odoo import api, models
class CustomReport(models.AbstractModel):
_name = 'report.custom_module.my_report'
description = 'desc'
@api.model
def _get_report_values(self, data=None):
return {
'docs': data,
'doc_model':'project.pdf.report',
'data': data['context']['x'],
}
When I don’t generate the report through the native print button instead, in the project model, the field <field name="print_report_name">
works fine. But through a custom button, it doesn’t, it keeps using the field <field name="name">
.
Any idea about how to change report file name through wizard?
Thanks a lot