Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
2548 Vistas

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
Descartar
Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
nov 19
8
1
abr 24
1564
2
mar 24
4323
1
ene 23
2789
1
abr 22
8842