changeset 9aed0f83ff34 in modules/account_payment_clearing:5.0
details:
https://hg.tryton.org/modules/account_payment_clearing?cmd=changeset;node=9aed0f83ff34
description:
Prevent calling succeed or fail with duplicate payments
issue9064
review266821003
(grafted from a548f3e2d37bd6937a02da007817ecd0191dca41)
diffstat:
statement.py | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diffs (40 lines):
diff -r f097cba15dc1 -r 9aed0f83ff34 statement.py
--- a/statement.py Sun Mar 01 21:03:48 2020 +0100
+++ b/statement.py Thu Mar 05 23:02:21 2020 +0100
@@ -19,28 +19,28 @@
moves = super(Statement, cls).create_move(statements)
- to_success = []
- to_fail = []
+ to_success = set()
+ to_fail = set()
for move, statement, lines in moves:
for line in lines:
if line.payment:
- payments = [line.payment]
+ payments = {line.payment}
kind = line.payment.kind
elif line.payment_group:
- payments = line.payment_group.payments
+ payments = set(line.payment_group.payments)
kind = line.payment_group.kind
else:
continue
if (kind == 'receivable') == (line.amount >= 0):
- to_success.extend(payments)
+ to_success.update(payments)
else:
- to_fail.extend(payments)
+ to_fail.update(payments)
# The failing should be done last because success is usually not a
# definitive state
if to_success:
- Payment.succeed(to_success)
+ Payment.succeed(Payment.browse(to_success))
if to_fail:
- Payment.fail(to_fail)
+ Payment.fail(Payment.browse(to_fail))
for move, statement, lines in moves:
assert len({l.payment for l in lines}) == 1