# Improve dynamic report filename

**URL:** https://discuss.tryton.org/t/improve-dynamic-report-filename/6405
**Category:** Ideas
**Created:** [August 3, 2023, 6:04pm UTC](https://discuss.tryton.org/t/improve-dynamic-report-filename/6405 "2023-08-03T18:04:25Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [August 3, 2023, 6:04pm UTC](https://discuss.tryton.org/t/improve-dynamic-report-filename/6405/1 "2023-08-03T18:04:26Z")

</div>

There are already some topics here on discuss but they are a bit old. The current situation with version 6.8 is that there is an extra field on the report record called `Record Name`. Using that field you can make the filename dynamic by adding data from the record. However the `Name` field is always added to the filename as well which in some cases is not preferred.  
Assume you have two reports which are exactly the same. One is for further editing and one will be exported to PDF which also have the company background. Even both reports are exactly the same the user will see two reports when clicking on the ‘report’ button:

1. Report for editing
2. PDF with company background

The user is seeing these names because they are added in the `Name` field on the report record. But the filename should be something along the lines of `WOB-346902.odt` or `WOB-346902.pdf`. The `346902` is the number of a particular record so it can be added to the `Record Name` as `WOB-${record.number}`.

Currently when getting the report the filenames will be

1. `Report-for-editing-WOB-346902.odt`
2. `PDF-with-company-background-WOB-346902.pdf`

In order to get only the `WOB-346902` for the filename I have to extend the `execute` function and create the filename myself.

So I would suggest to add a `Boolean` besides the `Record Name` and when checked it will only use the `Record Name` for the filename of the report. In some cases it can be handy to use both `Name` and `Record Name` but in other cases only `Record Name` is preferred.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [August 3, 2023, 9:03pm UTC](https://discuss.tryton.org/t/improve-dynamic-report-filename/6405/2 "2023-08-03T21:03:07Z")

</div>

I do not think such use case worth such addition.  
Indeed the use case seems more due to a wrong design. The report should be named “WOB” in both cases and use a wizard (or something else) to choose between each output.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [August 4, 2023, 7:03am UTC](https://discuss.tryton.org/t/improve-dynamic-report-filename/6405/3 "2023-08-04T07:03:08Z")

</div>

A possible improvement would be to add an optional name to the keyword, so it would be possible to use different display names in the keyword menus.  
This remind me a feature request (I could not find it) to group keyword actions to create one sub-level when there are too much actions. (@nicoe did not you start working on it?)

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [August 4, 2023, 7:17am UTC](https://discuss.tryton.org/t/improve-dynamic-report-filename/6405/4 "2023-08-04T07:17:13Z")

</div>

> [@edbo](#):
>
> So I would suggest to add a `Boolean` besides the `Record Name` and when checked it will only use the `Record Name` for the filename of the report. In some cases it can be handy to use both `Name` and `Record Name` but in other cases only `Record Name` is preferred.

I think it will be easier to include the `Record Name` as substitution for the filename.  
So the administrator will be able to decide if it is included or not (and also where it should be placed).

> [@ced](#):
>
> Indeed the use case seems more due to a wrong design. The report should be named “WOB” in both cases and use a wizard (or something else) to choose between each output.

I do not think a wizard is the proper solution but adding an extra step to fix the main issue.  
You will also have two reports on the system (due to different extension) so what are you will need to change the report filename in the wizard, which is the solution we already have before the “dynamic” filename was added.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [August 4, 2023, 7:26am UTC](https://discuss.tryton.org/t/improve-dynamic-report-filename/6405/5 "2023-08-04T07:26:34Z")

</div>

> [@pokoli](#):
>
> I think it will be easier to include the `Record Name` as substitution for the filename.  
> So the administrator will be able to decide if it is included or not (and also where it should be placed).

No because it is not translated.

> [@pokoli](#):
>
> I do not think a wizard is the proper solution but adding an extra step to fix the main issue.

An extra step for a rare case is not a problem.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [August 4, 2023, 7:29am UTC](https://discuss.tryton.org/t/improve-dynamic-report-filename/6405/6 "2023-08-04T07:29:59Z")

</div>

> [@ced](#):
>
> > [@pokoli](#):
> >
> > I think it will be easier to include the `Record Name` as substitution for the filename.  
> > So the administrator will be able to decide if it is included or not (and also where it should be placed).
> 
> No because it is not translated.

Why not? As far as now it is translated, the substitution will be already translated, should it?

> [@ced](#):
>
> An extra step for a rare case is not a problem.

IIRC this is the same argument as when we were discussion the addition of dynamic report.  
What is easy for core developers may not be as easy for system administrators (which may not know how to code).

---

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [August 4, 2023, 9:46am UTC](https://discuss.tryton.org/t/improve-dynamic-report-filename/6405/7 "2023-08-04T09:46:08Z")

</div>

> [@pokoli](#):
>
> I think it will be easier to include the `Record Name` as substitution for the filename.

Can you explain this a bit further? Are you saying that if `Record Name` is filled the `Name` is completely overwritten? If so, that’s what I hope for and we all can agree on. Because more and more everything becomes automated (like triggers etc) so to be able to set a custom and dynamic filename is in such case a must.

> [@ced](#):
>
> Indeed the use case seems more due to a wrong design. The report should be named “WOB” in both cases and use a wizard (or something else) to choose between each output.

This idea is from an administrator point of view which doesn’t have any skill in programming nor the interest. The administrator just duplicates an existing report and give it a certain `Name` and selects which `Extension` is needed. But the filename should be the same as the other report. In short, give the administrator extra possibilities to configure the filename of a report.

Also take the UX in consideration: 2 clicks for getting a report or at least 4 clicks and a popup window to get a report. It’s also confusing for the user to decide which button to click on, the `report` or `wizard` button. And last but not the least, when sending an email from the client you can attach a report.

> [@ced](#):
>
> > [@pokoli](#):
> >
> > I do not think a wizard is the proper solution but adding an extra step to fix the main issue.
> 
> An extra step for a rare case is not a problem.

Maybe it’s a rare case but I see that companies want to be able to:

1. send a report by email as PDF with the company background
2. print the report on company paper and send it by post
3. store the report outside Tryton on a server as PDF without the company background

When such a request comes in, I create just two reports which both links to the same template. Then a module is added to get the filename right and insert the company background in the PDF.

Of course I know ‘yes another thing to maintain’ but it’s a simple check and it already does a check [trytond/trytond/report/report.py · 550a4ecead8f9cadf243605f7fd4ef97c8ac382b · Tryton / Tryton · GitLab](https://foss.heptapod.net/tryton/tryton/-/blob/550a4ecead8f9cadf243605f7fd4ef97c8ac382b/trytond/trytond/report/report.py#L249)

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [August 4, 2023, 9:59am UTC](https://discuss.tryton.org/t/improve-dynamic-report-filename/6405/8 "2023-08-04T09:59:48Z")

</div>

> [@edbo](#):
>
> > [@pokoli](#):
> >
> > I think it will be easier to include the `Record Name` as substitution for the filename.
> 
> Can you explain this a bit further? Are you saying that if `Record Name` is filled the `Name` is completely overwritten? If so, that’s what I hope for and we all can agree on. Because more and more everything becomes automated (like triggers etc) so to be able to set a custom and dynamic filename is in such case a must.

I mean that the field to define the report name may accept some variables (like sequences do for years).  
So the system administrato will be able to decide if he wants to include or not. And more important, where the content should be included.

> [@edbo](#):
>
> Of course I know ‘yes another thing to maintain’ but it’s a simple check and it already does a check [trytond/trytond/report/report.py · 550a4ecead8f9cadf243605f7fd4ef97c8ac382b · Tryton / Tryton · GitLab](https://foss.heptapod.net/tryton/tryton/-/blob/550a4ecead8f9cadf243605f7fd4ef97c8ac382b/trytond/trytond/report/report.py#L249)

Thats another variable. Record name is the names of the records which are normally included on the report or not. That may be something that the system administrator should be able to decide also.

---

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [August 4, 2023, 10:04am UTC](https://discuss.tryton.org/t/improve-dynamic-report-filename/6405/9 "2023-08-04T10:04:56Z")

</div>

> [@pokoli](#):
>
> > [@edbo](#):
> >
> > Of course I know ‘yes another thing to maintain’ but it’s a simple check and it already does a check [trytond/trytond/report/report.py · 550a4ecead8f9cadf243605f7fd4ef97c8ac382b · Tryton / Tryton · GitLab](https://foss.heptapod.net/tryton/tryton/-/blob/550a4ecead8f9cadf243605f7fd4ef97c8ac382b/trytond/trytond/report/report.py#L249)
> 
> Thats another variable. Record name is the names of the records which are normally included on the report or not. That may be something that the system administrator should be able to decide also.

Ok, but when I remove the `filter` and just leave the `report_name(....)` I get the desired result.

---

<div class="post-metadata">

### Author: ![nicoe](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/nicoe/32/2880_2.png) [@nicoe](https://discuss.tryton.org/u/nicoe)
#### Post date: [August 16, 2023, 6:42am UTC](https://discuss.tryton.org/t/improve-dynamic-report-filename/6405/10 "2023-08-16T06:42:50Z")

</div>

> [@ced](#):
>
> This remind me a feature request (I could not find it) to group keyword actions to create one sub-level when there are too much actions. (@nicoe did not you start working on it?)

Yes I did but the budget has never been accepted so I stopped working on it. I could upload the topic as a WIP though.
