Skip to Content
Menu
This question has been flagged
2 Replies
569 Views

Is there a way to customize the name of the files I download from Odoo automatically, in order to, for example, add the name of the client?

Avatar
Discard
Author Best Answer
  1. Enable developer mode from settings
  2. Enter Studio and open the report you want to edit


Note: If you don’t have Studio you can look for the report inside the reports model:


3. Click on “More” (Only visible with developer mode enabled)


4. Change “Printed Report Name”

Example: ‘Sale number ‘ + (object.name) + ‘ for ‘ + (object.partner_id.name)


Explanation of the structure:

  • Use quotes (‘’) in case you want to add specific text
  • Use “+” to concatenate different elements
  • Use object.field between parenthesis to specify a field to use. Make sure to use the technical name of the field


Or  

  • Put all the text between quotes (‘’), 
  • Inside this same text, specify the fields using “%s”, 
  • Add “%” out of the quotes 
  • Add all the technical names of the fields between parenthesis (adding “object”, and separated by commas as shown below)


Example: 'Sale number %s for %s' % (object.name, object.partner_id.name)


Note that you can retrieve fields from inside other records like the name of the client in a sale order (object.partner_id.name), just make sure which fields are available in the corresponding model


You can even use new fields added with studio!


Tip: Enable developer mode from settings to see the technical name of the fields when positioning the mouse over the “?” symbol


Example of client field:


Result of the example showed above: 


Additional note: If not done correctly, it will cause an error when trying to download the file


Side note: From V18 the invoice file name is the same as the XML file name in mexican localization

Avatar
Discard
Best Answer
If you are paying Studio:
  1. Open Studio in the model where is located the file:


2. Select the report

3. In developer mode, click on "more":

4. In this case, I am going to add the name of the client/provider:

(object.state in ('posted', 'sent') and 'Invoice_'  + (object.name)  +  '-'  + (object.partner_id.name))


Without Studio:


  1. Go to Settings/Technical/Actions/Reports
  2. Select the report:

This one is for invoices.


Avatar
Discard
Related Posts Replies Views Activity
5
May 25
13609
1
May 25
383
1
May 25
11
1
Apr 25
500
0
Jan 25
917