Issue 10409

Title
Printing reports without any selected record crashes
Priority
bug
Status
chatting
Superseder
Set button state in message_callback (issue 10410)
Nosy list
ced, oscar, pokoli
Assigned to
Keywords
backport

Created on 2021-05-12.09:32:08 by pokoli, last changed 2 weeks ago by ced.

Messages

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2021-05-31.15:42:28

I see that by the number of issue reported for this problem that many people are using reports with an empty list of records. Even if it is not really a good usage and for me there should always be at least one record in the list (even if it must be the company), I think we could improve the code to work with empty list by using fallback values where needed and keep the side effect of previous version.
But issue10410 should still be fixed because by default as it use bad experience for the user to get an empty report.

Author: [hidden] (oscar)
Date: 2021-05-31.15:37:34

Anyway it fails, with model or without model, and I was checking the code and is a bug, for me.

Author: [hidden] (pokoli) Tryton committer Tryton translator
Date: 2021-05-31.15:25:30

Then do not set any model for the record.

Author: [hidden] (oscar)
Date: 2021-05-31.15:12:13

def do_print_(self, action):
data = {
'ids': [],
'company': self.start.company.id,
'fiscalyear': self.start.fiscalyear.id,
'start_period': start_period,
'end_period': end_period,
}
return action, data

We need empty list for ids in Reports from wizards, because some reports are very complex and not neccesary is related with specific records and model, some are combination of several models and records. In Colombia we have more 20 reports (sales, goverment reports, purchase, staff) with in this way, this change mean our customers could not see all this reports again

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2021-05-12.09:49:13

For me it is not expected to run report without records (just like wizard, etc.).
So it is just about implementing issue10410.

Author: [hidden] (pokoli) Tryton committer Tryton translator
Date: 2021-05-12.09:32:08

I get several tracebacks when printing reports without any selected record. I expect an empty report is shown instead of a traceback.

On 6.0 series, from sale or invoice report I get the following traceback:

Traceback (most recent call last):
  File "/usr/local/lib/python37/dist-packages/trytond/wsgipy", line 117, in dispatch_request
    return endpoint(request, **requestview_args)
  File "/usr/local/lib/python37/dist-packages/trytond/protocols/dispatcherpy", line 48, in rpc
    request, database_name, *requestrpc_params)
  File "/usr/local/lib/python37/dist-packages/trytond/wsgipy", line 84, in auth_required
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python37/dist-packages/trytond/protocols/wrapperspy", line 156, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/usr/local/lib/python37/dist-packages/trytond/protocols/dispatcherpy", line 181, in _dispatch
    result = rpcresult(meth(*c_args, **c_kwargs))
  File "/usr/local/lib/python37/dist-packages/trytond/modules/sale/salepy", line 1777, in execute
    return super(SaleReport, cls)execute(ids, data)
  File "/usr/local/lib/python37/dist-packages/trytond/report/reportpy", line 194, in execute
    groups[0], headers[0], data, action_report)
IndexError: list index out of range

On 5.8 series, on the invoice report (sale reports works well) I get the following traceback:

Traceback (most recent call last):
  File "/usr/local/lib/python37/dist-packages/trytond/wsgipy", line 116, in dispatch_request
    return endpoint(request, **requestview_args)
  File "/usr/local/lib/python37/dist-packages/trytond/protocols/dispatcherpy", line 48, in rpc
    request, database_name, *requestrpc_params)
  File "/usr/local/lib/python37/dist-packages/trytond/wsgipy", line 83, in auth_required
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python37/dist-packages/trytond/protocols/wrapperspy", line 131, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/usr/local/lib/python37/dist-packages/trytond/protocols/dispatcherpy", line 181, in _dispatch
    result = rpcresult(meth(*c_args, **c_kwargs))
  File "/usr/local/lib/python37/dist-packages/trytond/modules/account_invoice/invoicepy", line 2629, in execute
    return super()execute(ids, data)
  File "/usr/local/lib/python37/dist-packages/trytond/report/reportpy", line 165, in execute
    oext, content = cls_execute(records, data, action_report)
  File "/usr/local/lib/python37/dist-packages/trytond/modules/account_invoice/invoicepy", line 2601, in _execute
    invoice, = Invoicebrowse(records)
ValueError: not enough values to unpack (expected 1, got 0)

Both can be reproduced on demo server by just deselecting the records and using the print action of the modules.

History
Date User Action Args
2021-05-31 15:42:28cedsetcomponent: - account_invoice
keyword: + backport
messages: + msg67896
status: invalid -> chatting
2021-05-31 15:37:34oscarsetmessages: + msg67895
2021-05-31 15:36:08cedlinkissue10477 superseder
2021-05-31 15:25:30pokolisetmessages: + msg67894
2021-05-31 15:12:13oscarsetmessages: + msg67893
nosy: + oscar
2021-05-16 11:01:12cedlinkissue10426 superseder
2021-05-14 18:10:20cedlinkissue10423 superseder
2021-05-12 09:49:13cedsetmessages: + msg67526
nosy: + ced
status: unread -> invalid
superseder: + Set button state in message_callback
2021-05-12 09:32:08pokolicreate

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