Skip to Content
Menu
This question has been flagged
1 Reply
2507 Views

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
Discard
Best Answer

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
Discard
Related Posts Replies Views Activity
0
Nov 19
8
1
Apr 24
1543
2
Mar 24
4264
1
Jan 23
2763
1
Apr 22
8813