Issue 10409

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

Created on 2021-05-12.09:32:08 by pokoli, last changed 1 month ago by roundup-bot.

Files

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

Messages

New changeset 947d458462af by Cédric Krier in branch '6.0':
Allow to execute reports without records
https://hg.tryton.org/trytond/rev/947d458462af
New changeset c470e7b7c3f1 by Cédric Krier in branch '6.0':
Allow to execute reports without records
https://hg.tryton.org/modules/stock/rev/c470e7b7c3f1
New changeset 54221d23053d by Cédric Krier in branch '6.0':
Allow to execute reports without records
https://hg.tryton.org/modules/sale/rev/54221d23053d
New changeset eb7eea6ae44b by Cédric Krier in branch '6.0':
Allow to execute reports without records
https://hg.tryton.org/modules/purchase_request_quotation/rev/eb7eea6ae44b
New changeset 3b725f47923c by Cédric Krier in branch '6.0':
Allow to execute reports without records
https://hg.tryton.org/modules/purchase/rev/3b725f47923c
New changeset efca625653e3 by Cédric Krier in branch '6.0':
Allow to execute reports without records
https://hg.tryton.org/modules/company/rev/efca625653e3
New changeset e4f84cd86551 by Cédric Krier in branch '6.0':
Allow to execute reports without records
https://hg.tryton.org/modules/account_statement/rev/e4f84cd86551
New changeset caf7ac51f4ae by Cédric Krier in branch '6.0':
Allow to execute reports without records
https://hg.tryton.org/modules/account_payment_sepa/rev/caf7ac51f4ae
New changeset 05219601678b by Cédric Krier in branch '6.0':
Allow to execute reports without records
https://hg.tryton.org/modules/account_dunning_letter/rev/05219601678b
New changeset b3902b16735b by Cédric Krier in branch '6.0':
Allow to execute reports without records
https://hg.tryton.org/modules/account_asset/rev/b3902b16735b
New changeset 9ed5c0969983 by Cédric Krier in branch 'default':
Allow to execute reports without records
https://hg.tryton.org/tryton-env/rev/9ed5c0969983
New changeset df00526a82b2 by Cédric Krier in branch 'default':
Allow to execute reports without records
https://hg.tryton.org/trytond/rev/df00526a82b2
New changeset 24a670b0fd66 by Cédric Krier in branch 'default':
Allow to execute reports without records
https://hg.tryton.org/modules/stock/rev/24a670b0fd66
New changeset 58474f291d00 by Cédric Krier in branch 'default':
Allow to execute reports without records
https://hg.tryton.org/modules/sale/rev/58474f291d00
New changeset 7f7838674289 by Cédric Krier in branch 'default':
Allow to execute reports without records
https://hg.tryton.org/modules/purchase_request_quotation/rev/7f7838674289
New changeset 1e2f5cb3760f by Cédric Krier in branch 'default':
Allow to execute reports without records
https://hg.tryton.org/modules/purchase/rev/1e2f5cb3760f
New changeset 14afd35c475e by Cédric Krier in branch 'default':
Allow to execute reports without records
https://hg.tryton.org/modules/company/rev/14afd35c475e
New changeset 85d1bb950e2d by Cédric Krier in branch 'default':
Allow to execute reports without records
https://hg.tryton.org/modules/account_statement/rev/85d1bb950e2d
New changeset e7da72126c58 by Cédric Krier in branch 'default':
Allow to execute reports without records
https://hg.tryton.org/modules/account_payment_sepa/rev/e7da72126c58
New changeset 557fbac32d5e by Cédric Krier in branch 'default':
Allow to execute reports without records
https://hg.tryton.org/modules/account_dunning_letter/rev/557fbac32d5e
New changeset d8e35d801b41 by Cédric Krier in branch 'default':
Allow to execute reports without records
https://hg.tryton.org/modules/account_asset/rev/d8e35d801b41
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-09-10 19:58:27roundup-botsetmessages: + msg70021
2021-09-10 19:57:45roundup-botsetmessages: + msg70013
2021-09-10 19:57:38roundup-botsetmessages: + msg70011
2021-09-10 19:57:36roundup-botsetmessages: + msg70010
2021-09-10 19:57:33roundup-botsetmessages: + msg70009
2021-09-10 19:57:21roundup-botsetmessages: + msg70007
2021-09-10 19:57:10roundup-botsetmessages: + msg70006
2021-09-10 19:57:03roundup-botsetmessages: + msg70005
2021-09-10 19:56:41roundup-botsetmessages: + msg70004
2021-09-10 19:56:22roundup-botsetkeyword: - backport
messages: + msg70001

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