changeset 224caeb8607e in modules/account_payment_clearing:default
details:
https://hg.tryton.org/modules/account_payment_clearing?cmd=changeset&node=224caeb8607e
description:
Do not fail on missing clearing line
issue10757
diffstat:
payment.py | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diffs (32 lines):
diff -r bfbbedb37abd -r 224caeb8607e payment.py
--- a/payment.py Sun Nov 28 18:56:16 2021 +0100
+++ b/payment.py Mon Nov 29 21:27:00 2021 +0100
@@ -129,15 +129,19 @@
amount = super().amount_line_paid
if self.clearing_move:
- clearing_line = [l for l in self.clearing_move.lines
- if l.account == self.clearing_account][0]
- if (not self.line.reconciliation
- and clearing_line.reconciliation):
- if self.line.second_currency:
- payment_amount = abs(self.line.amount_second_currency)
- else:
- payment_amount = abs(self.line.credit - self.line.debit)
- amount -= max(min(self.amount, payment_amount), 0)
+ clearing_lines = [
+ l for l in self.clearing_move.lines
+ if l.account == self.clearing_account]
+ if clearing_lines:
+ clearing_line = clearing_lines[0]
+ if (not self.line.reconciliation
+ and clearing_line.reconciliation):
+ if self.line.second_currency:
+ payment_amount = abs(self.line.amount_second_currency)
+ else:
+ payment_amount = abs(
+ self.line.credit - self.line.debit)
+ amount -= max(min(self.amount, payment_amount), 0)
return amount
@classmethod