Tryton - Issues



Title couldn't delete statement with lines
Priority bug Status resolved
Superseder Nosy List ced, pokoli, reviewbot, roundup-bot, semarie
Type crash Components account_statement
Assigned To pokoli Keywords review
Reviews 49561002
View: 49561002

Created on 2018-09-10.06:46:44 by semarie, last changed by roundup-bot.

New changeset 50116d7cf90d by Sergi Almacellas Abellana in branch 'default':
Test if move is set before reading its lines
New changeset 3d7e57dc55be by Sergi Almacellas Abellana in branch 'default':
Test if move is set before reading its lines
review49561002 updated at
msg43779 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2018-09-10.09:36:12
I agree keeping the list comprehension makes sense and is probably more efficient.
msg43777 (view) Author: [hidden] (semarie) Date: 2018-09-10.09:28:32
hep, it fixes it.

if you want to keep list comprehension, I think spliting/reordering the `if` clause should do the trick:

diff -r 7de89d79245e
--- a/      Sun Sep 09 10:08:22 2018 +0200
+++ b/      Mon Sep 10 09:21:50 2018 +0200
@@ -838,8 +838,8 @@
         Reconciliation = pool.get('account.move.reconciliation')

         reconciliations = [l.reconciliation
-            for line in lines for l in line.move.lines
-            if line.move and l.reconciliation]
+            for line in lines if line.move
+            for l in line.move.lines if l.reconciliation]
         Move.delete(list({l.move for l in lines if l.move}))

it fixes my usecase, but I am not confident enought in my python skill to be sure to be right in all cases.
review49561002 updated at
msg43775 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2018-09-10.09:14:15
Here is review49561002 that should fix it. Could you please test it?
msg43772 (view) Author: [hidden] (semarie) Date: 2018-09-10.06:46:43
If I try to delete a statement (in 'draft' state) whereas some lines were already filled, I have the following exception:

Traceback (most recent call last):
  File "/trytond/", line 73, in dispatch_request
    return endpoint(request, **request.view_args)
  File "/trytond/protocols/", line 46, in rpc
    request, database_name, *request.rpc_params)
  File "/trytond/", line 44, in auth_required
    return wrapped(*args, **kwargs)
  File "/trytond/protocols/", line 122, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/trytond/protocols/", line 176, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/trytond/modules/account_statement/", line 372, in delete
  File "/trytond/model/", line 666, in wrapper
    return func(cls, records, *args, **kwargs)
  File "/trytond/model/", line 36, in wrapper
    result = func(cls, filtered, *args, **kwargs)
  File "/trytond/modules/account_statement/", line 555, in cancel
  File "/trytond/modules/account_statement/", line 841, in delete_move
    for line in lines for l in line.move.lines
  File "/trytond/modules/account_statement/", line 841, in <listcomp>
    for line in lines for l in line.move.lines
AttributeError: 'NoneType' object has no attribute 'lines'

Please note that manually delete the lines, save the record, and next delete the statement works as excepted.

To reproduce:
- create a new Statement (with amount validation for example)
- add a StatementLine
- save the record
- delete the record : the exception is triggered
Date User Action Args
2018-09-17 09:46:58roundup-botsetmessages: + msg43915
2018-09-17 09:46:53roundup-botsetstatus: testing -> resolved
nosy: + roundup-bot
messages: + msg43914
2018-09-10 09:55:08reviewbotsetmessages: + msg43781
2018-09-10 09:36:12cedsetnosy: + ced
messages: + msg43779
2018-09-10 09:28:33semariesetmessages: + msg43777
2018-09-10 09:26:07reviewbotsetnosy: + reviewbot
messages: + msg43776
2018-09-10 09:14:20pokolisetstatus: chatting -> testing
2018-09-10 09:14:16pokolisetstatus: unread -> chatting
keyword: + review
nosy: + pokoli
messages: + msg43775
reviews: 49561002
assignedto: pokoli
2018-09-10 06:46:44semariecreate

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