[FIX] account: fix potential traceback
`all([]) = True`, therefore if there is no `matched_debit_ids` or `matched_credit_ids` on a payment ==> boom when you access `payment.matched_debit_ids[0]` opw-677157 Closes #12232 Closes #12242
This commit is contained in:
committed by
Nicolas Martinelli
parent
f413d155df
commit
272c7b26fc
@@ -148,14 +148,17 @@ class AccountInvoice(models.Model):
|
||||
info = {'title': _('Less Payment'), 'outstanding': False, 'content': []}
|
||||
currency_id = self.currency_id
|
||||
for payment in self.payment_move_line_ids:
|
||||
payment_currency_id = False
|
||||
if self.type in ('out_invoice', 'in_refund'):
|
||||
amount = sum([p.amount for p in payment.matched_debit_ids if p.debit_move_id in self.move_id.line_ids])
|
||||
amount_currency = sum([p.amount_currency for p in payment.matched_debit_ids if p.debit_move_id in self.move_id.line_ids])
|
||||
payment_currency_id = all([p.currency_id == payment.matched_debit_ids[0].currency_id for p in payment.matched_debit_ids]) and payment.matched_debit_ids[0].currency_id or False
|
||||
if payment.matched_debit_ids:
|
||||
payment_currency_id = all([p.currency_id == payment.matched_debit_ids[0].currency_id for p in payment.matched_debit_ids]) and payment.matched_debit_ids[0].currency_id or False
|
||||
elif self.type in ('in_invoice', 'out_refund'):
|
||||
amount = sum([p.amount for p in payment.matched_credit_ids if p.credit_move_id in self.move_id.line_ids])
|
||||
amount_currency = sum([p.amount_currency for p in payment.matched_credit_ids if p.credit_move_id in self.move_id.line_ids])
|
||||
payment_currency_id = all([p.currency_id == payment.matched_credit_ids[0].currency_id for p in payment.matched_credit_ids]) and payment.matched_credit_ids[0].currency_id or False
|
||||
if payment.matched_credit_ids:
|
||||
payment_currency_id = all([p.currency_id == payment.matched_credit_ids[0].currency_id for p in payment.matched_credit_ids]) and payment.matched_credit_ids[0].currency_id or False
|
||||
# get the payment value in invoice currency
|
||||
if payment_currency_id and payment_currency_id == self.currency_id:
|
||||
amount_to_show = amount_currency
|
||||
|
||||
Reference in New Issue
Block a user