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

I have a table in an odoo studio report and want to sort it by e.g. field called "start_date"

and then sort it by a second field called "name"


how do I do this in studio? Manual xml adaption would be ok, if someone can tell what needs to be added or changed and where.

Avatar
Zrušit
Nejlepší odpověď

Hi,

In Odoo Studio, you can achieve sorting by multiple fields in a report by manually adding XML code to the report's template. Here's how you can do it:

  1. Open the report in Odoo Studio.
  2. Switch to the "Advanced Mode" to access the XML view of the report template.
  3. Locate the tag in the XML code. This tag is used to retrieve records from the database.
  4. Add the following code after the tag to sort the records by multiple fields:
r.name))"/>

Replace 'your_model_name' with the actual name of the model you're using in the report.

In the above code, r.start_date and r.name are the fields by which you want to sort the records. You can replace them with the actual field names as per your requirement. The sorted() method is used to sort the records based on the specified fields.

  1. Replace the usage of records with records_sorted in the subsequent code where you iterate over the records to display them in the report. For example:
    

  1. Save the changes and preview the report to verify that the records are sorted as expected.

Following these steps, you can manually add sorting by multiple fields to a report in Odoo Studio. Remember to replace 'your_model_name' with the actual model name and adjust the field names as needed, You can try this it may meet your requirement


Hope it helps

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
lis 19
8
1
dub 24
1546
2
bře 24
4283
1
led 23
2765
1
dub 22
8827