Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
4651 Zobrazení

Hello,

I would like to change PDF Invoice name for attached file witch generate from PDF Menu. I know how to do this from interface using Settings -> Technical -> Reports, but I would like to make this in my custom module. I do not have idea how. Now the name of file is 300000001.pdf but I would like to be Invoice-3000000001.pdf.

Thanks a lot
Avatar
Zrušit
Autor

It is urgent. I will be happy if someone can help us.

Nejlepší odpověď
<record id="account.account_invoices" model="ir.actions.report"> 
    <field name="print_report_name">'Invoices-%s' % object.number</field>
</record>
Avatar
Zrušit
Nejlepší odpověď

Hi,
You have to find the external id of the report. Then you have to create an XML file and add a record.

<record id=”external_id” model=”account.move”>
<field name=”print_report_name”>new name</field>
</record>

Here replace the external Id with the actual external id of the original report. You can also generate file names using functions. If the standard report may generate the file name from a function. So you have to change or override the function also.

Hope it helps

Avatar
Zrušit
Autor Nejlepší odpověď

I ask for odoo v.14. I try this one, but doenst work:


<record id="report_invoice_document_inherit_generix" model="ir.actions.report">
<field name="model">account.move</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">account.report_invoice_document</field>
<field name="report_file">account.report_invoice_document</field>
<field name="print_report_name">'Invoice-%s' % (object.name)</field>
</record>


I have one xml file where I inherit invoice template and I start with this code, and everything work there and print my template, but I dont know how to change file name:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_invoice_document_inherit_generix" inherit_id="account.report_invoice_document">
<xpath expr="//t[@t-call='web.external_layout']" position="replace">


Avatar
Zrušit

<record id="account.account_invoices" model="ir.actions.report">

<field name="print_report_name">'Invoices-%s' % object.number</field>

</record>

Autor

Thanks, but does not work. Nothing change. The name is the same.

Autor

Kiran thanks for your ideas but doesnt work. Maybe the idea to inherit the class is the best but I do not have idea how to do. Can you help?