跳至內容
選單
此問題已被標幟
3 回覆
4664 瀏覽次數

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
頭像
捨棄
作者

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

最佳答案
<record id="account.account_invoices" model="ir.actions.report"> 
    <field name="print_report_name">'Invoices-%s' % object.number</field>
</record>
頭像
捨棄
最佳答案

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

頭像
捨棄
作者 最佳答案

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">


頭像
捨棄

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

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

</record>

作者

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

作者

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?