Issue 9500

Title
crash general ledger report when move line has reference but without object.
Priority
bug
Status
resolved
Nosy list
ced, lukio, reviewbot, roundup-bot
Assigned to
ced
Keywords
review

Created on 2020-07-24.14:28:41 by lukio, last changed 1 month ago by roundup-bot.

Files

File name Uploaded Type Details
ksnip_20200724-093148.png lukio, 2020-07-24.14:35:06 image/png view

Messages

New changeset f438a1981037 by Cédric Krier in branch '5.6':
Use getattr instead of testing origin id
https://hg.tryton.org/modules/account/rev/f438a1981037

New changeset fcbba39920d0 by Cédric Krier in branch '5.4':
Use getattr instead of testing origin id
https://hg.tryton.org/modules/account/rev/fcbba39920d0

New changeset c73d8d1545e4 by Cédric Krier in branch '5.0':
Use getattr instead of testing origin id
https://hg.tryton.org/modules/account/rev/c73d8d1545e4
New changeset ae4f5ee9e446 by Cédric Krier in branch 'default':
Use getattr instead of testing origin id
https://hg.tryton.org/tryton-env/rev/ae4f5ee9e446
New changeset 64b7fe636940 by Cédric Krier in branch 'default':
Use getattr instead of testing origin id
https://hg.tryton.org/modules/account/rev/64b7fe636940
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2020-10-24.22:44:12

Similar to issue7437, here is review304611002

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2020-07-24.15:38:30
It happens since rev b8d76b07910f so the test added in rev 7a2b91535911 does not work anymore.
I think the solution would be to test if origin is an instance of Record.
Author: [hidden] (lukio)
Date: 2020-07-24.14:28:40
tested on demo v5.6 and demo v5.0

Reproduce:

1. Create a new account move.
2. Add move lines. One of them set the origin but without any object (added an screenshot).

3. Try to generate general ledger odt report and crash because origin id is set to -1.

Traceback (most recent call last):
  File "/genshi/template/evalpy", line 318, in lookup_attr
    val = getattr(obj, key)
AttributeError: 'str' object has no attribute 'id'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/genshi/template/evalpy", line 324, in lookup_attr
    val = obj[key]
TypeError: string indices must be integers

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python37/dist-packages/trytond/wsgipy", line 109, 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 77, 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/report/reportpy", line 204, in execute
    oext, content = cls_execute(records, data, action_report)
  File "/usr/local/lib/python37/dist-packages/trytond/report/reportpy", line 212, in _execute
    return clsconvert(action, clsrender(action, report_context))
  File "/usr/local/lib/python37/dist-packages/trytond/report/reportpy", line 314, in render
    data = rel_report(**report_context)render()
  File "/usr/local/lib/python37/dist-packages/relatorio/templates/basepy", line 35, in render
    selfevents, method=method, encoding=encoding, out=out)
  File "/usr/local/lib/python37/dist-packages/relatorio/templates/opendocumentpy", line 1169, in __call__
    selfxml_serializer(writer(stream)), encoding=encoding, out=writer)
  File "/genshi/outputpy", line 58, in encode
    for chunk in iterator:
  File "/genshi/outputpy", line 241, in __call__
    for kind, data, pos in stream:
  File "/genshi/outputpy", line 671, in __call__
    for kind, data, pos in stream:
  File "/genshi/outputpy", line 776, in __call__
    for kind, data, pos in chain(stream, [(None, None, None)]):
  File "/genshi/outputpy", line 596, in __call__
    for ev in stream:
  File "/usr/local/lib/python37/dist-packages/relatorio/templates/opendocumentpy", line 1061, in __call__
    for kind, data, pos in stream:
  File "/genshi/corepy", line 292, in _ensure
    for event in stream:
  File "/genshi/filters/i18npy", line 691, in __call__
    for kind, data, pos in stream:
  File "/genshi/template/basepy", line 638, in _include
    for event in stream:
  File "/genshi/template/markuppy", line 327, in _match
    for event in stream:
  File "/genshi/template/basepy", line 598, in _flatten
    result = _eval_expr(data, ctxt, vars)
  File "/genshi/template/basepy", line 289, in _eval_expr
    retval = exprevaluate(ctxt)
  File "/genshi/template/evalpy", line 178, in evaluate
    return eval(selfcode, _globals, {'__data__': data})
  File "<string>", line 558, in <Expression "__relatorio_escape_invalid_chars(lineoriginrec_name if lineorigin and lineoriginid >= 0 else '')">
  File "/genshi/template/evalpy", line 326, in lookup_attr
    val = clsundefined(key, owner=obj)
  File "/genshi/template/evalpy", line 414, in undefined
    raise UndefinedError(key, owner=owner)
genshitemplateevalUndefinedError: 'accountmoveline,-1' has no member named "id"
History
Date User Action Args
2020-10-30 19:58:04roundup-botsetkeyword: - backport
messages: + msg61558
2020-10-25 11:02:48roundup-botsetmessages: + msg61391
2020-10-25 11:02:42roundup-botsetmessages: + msg61390
nosy: + roundup-bot
status: testing -> resolved
2020-10-24 23:00:01reviewbotsetmessages: + msg61374
nosy: + reviewbot
2020-10-24 22:44:13cedsetassignedto: ced
keyword: + backport, review
messages: + msg61373
reviews: 304611002
status: chatting -> testing
2020-07-24 15:38:30cedsetstatus: unread -> chatting
nosy: + ced
messages: + msg59472
2020-07-24 14:35:06lukiosetfiles: + ksnip_20200724-093148.png
2020-07-24 14:34:34lukiosetfiles: - 2020-07-24-092644_1366x768_scrot.png
2020-07-24 14:28:41lukiocreate

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