Odoo13: How to 'Group By' in the 'Export Data' screen when exporting to xlsx

376 views Asked by At

Run Odoo13 CE locally, go to any list view, Contacts for example. Select some records and select "Export" from Actions menu, then export to xlsx, this works fine. Now I need to do "Group By", for this I traced the code to know how export works, and I found in the file

addons/web/controllers/main.py

a method 'base' that is being called in every export

def base(self, data, token):
    params = json.loads(data)
...
   
    groupby = params.get('groupby')
    if not import_compat and groupby:
        groupby_type = [Model._fields[x.split(':')[0]].type for x in groupby]
...

I need to send a "Group By" field to this method among the other parameters, but I can not find a clue how to do that, any help would be greatly appreciated.

1

There are 1 answers

0
tarek mohamed On BEST ANSWER

I got it. Just make a "Group By" one or more than one fields in the list view, select the records you need to export and then click the "Export" menu item from the actions menu. You will see the result xlsx file grouped by the fields you selected