Improve dynamic report filename

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.

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.

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?)

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).

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.

No because it is not translated.

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

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

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).

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.

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.

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

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.

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.

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.