Issue 10409

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

Created on 2021-05-12.09:32:08 by pokoli, last changed 5 days ago by rvong.

Files

File name Uploaded Type Details
report_py.patch rvong, 2021-07-27.21:59:41 text/plain view

Messages

Author: [hidden] (rvong)
Date: 2021-07-29.19:45:31

Many thanks for your answers!

Author: [hidden] (pokoli) Tryton committer Tryton translator
Date: 2021-07-29.16:50:42
  1. The testing is done manually by other users. Once you submit a codereview our bots will work on it to check flake8 and syntax. Nothing to do for your side.
  2. It's right to submit the patch to default branch. Once the patch is accepted and after some testing in default it will be backported to 6.0 series by our project leader.
  3. You can find us on the #tryton channel in IRC network to answer this kind of questions.

P.D: If you have more questions could you please ask them in our discuss forum so there are more people will read (and probably also answer). Thanks.

Author: [hidden] (rvong)
Date: 2021-07-29.16:38:12

Please assign the issue to yourself if you are going to work on it and set the status to testing if the issue is ready to test.

Done!
But I have many questions to ask:
1- Is the testing done automatically once submitted to codereview? Or do I have to flag something in order to start the testing?
2- I summited the patch based on the default branch, however, I am working on branch 6.0. If I were to submit patches for 6.0 how does codereview knows which branch is?
3- I noticed there is a note about moving to a new IRC server. I never used IRC before and would like to know it is ready and what's the link for asking development related questions like these.

Author: [hidden] (pokoli) Tryton committer Tryton translator
Date: 2021-07-29.16:16:25

Please assign the issue to yourself if you are going to work on it and set the status to testing if the issue is ready to test.

Author: [hidden] (rvong)
Date: 2021-07-29.16:12:25

Thank you Sergi.
Right after I wrote my previous note, I figured out that the upload.py tool uploads the patch onto codereview site and not this one (bugs) so the issue ID on this site and the ones from codereview are unrelated. I just uploaded the patch without the "-i" option and everything went smooth.

Here is the codereview link 355391002

Author: [hidden] (pokoli) Tryton committer Tryton translator
Date: 2021-07-29.16:08:31

You should not use the -i flag when updating a new review.
The tools will create a new id for each review (which you should introduce in the reviews field of the bug tracker).
Latter, if we request any fix on your patch, you can update the codereview by using the -i flag and the review_id that was generated by the system.

Author: [hidden] (rvong)
Date: 2021-07-29.15:53:36

I need some guidance on how to use the upload.py tool.
I put the command

python ~/bin/upload.py -i 10409

but I got a message saying

Issue creation errors: {'issue': ['No issue exists with that id (10409)']}
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2021-07-27.23:57:21
Author: [hidden] (rvong)
Date: 2021-07-27.21:59:41

I just upgraded to version 6.0 and this bug started to affect my custom reports. Like Oscar says, some reports are very complex (for example digest or summary) and not necessarily related to a single record/model, hence I wish the empty list of records can be maintained as in previous versions.
I have attached a patch that I am using to fix this error if anyone is interested. This patch modifies trytond/report/report.py

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-07-29 19:45:31rvongsetmessages: + msg69093
2021-07-29 16:50:42pokolisetmessages: + msg69092
2021-07-29 16:38:12rvongsetassignedto: rvong
messages: + msg69091
status: chatting -> testing
2021-07-29 16:16:25pokolisetmessages: + msg69090
2021-07-29 16:15:41rvongsetreviews: https://codereview.tryton.org/355391002/ -> 355391002
2021-07-29 16:14:35rvongsetkeyword: + review
reviews: https://codereview.tryton.org/355391002/
status: in-progress -> chatting
2021-07-29 16:12:25rvongsetmessages: + msg69089
status: chatting -> in-progress
2021-07-29 16:08:31pokolisetmessages: + msg69088
2021-07-29 15:53:36rvongsetmessages: + msg69087
2021-07-27 23:57:21cedsetmessages: + msg69060

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