Issue 10477

Reports fail when ids is empty
Printing reports without any selected record crashes (issue 10409)
Nosy list
oscar, pokoli
Assigned to

Created on 2021-05-31.14:47:14 by oscar, last changed 4 months ago by ced.


Author: [hidden] (pokoli) Tryton committer Tryton translator
Date: 2021-05-31.14:58:24

Duplicate issue10409

Author: [hidden] (oscar)
Date: 2021-05-31.14:47:14

In 6.0 version reports fail when we try pass empty list to ids

Traceback (most recent call last):
File "/home/psk/.virtualenvs/tryton60/lib/python3.9/site-packages/trytond/protocols/", line 181, in _dispatch
result = rpc.result(meth(c_args, *c_kwargs))
File "/home/psk/.virtualenvs/tryton60/lib/python3.9/site-packages/trytond/report/", line 194, in execute
groups[0], headers[0], data, action_report)
IndexError: list index out of range

for example

def do_print_(self, action):
    data = {
        'ids': [],
        'start_period': start_period,
        'end_period': end_period,
    return action, data

We need empty list because some reports are very complex and not neccesary is related with specific records and model, maybe are combination of several models and records.

In report/, I tried fix it with this change

        groups = groups[0] if groups else []
        headers = headers[0] if headers else []
        oext, content = cls._execute(
            groups, headers, data, action_report)**

With this works!, I can to submit patch?

Date User Action Args
2021-05-31 15:36:08cedsetsuperseder: + Printing reports without any selected record crashes
2021-05-31 14:58:24pokolisetmessages: + msg67892
nosy: + pokoli
status: unread -> invalid
2021-05-31 14:47:14oscarcreate

Showing 10 items. Show all history (warning: this could be VERY long)