[FIX] account: fix IndexError in payment terms

If applied, this commit will solve the tuple index out of range error when the
'Percent' value is not set in the Due Terms and the user tries to add 'Fixed'
value in more than one line.

To reproduce this issue, follow the steps.
- Open Accounting -> Configuration -> invoicing -> payment terms.
- Open any payment term, and change the value from 'Percent' to 'Fixed' in Due
  Terms.
- Add another line with a value as 'Fixed'.

see-https://tinyurl.com/22e2yj2a

sentry-4072967091

closes odoo/odoo#119131

X-original-commit: fcb3c237e24ec44fd6df0de5f2a0f329efb1bf13
Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
Renilkumar Kajavadra
2023-04-20 00:50:00 +02:00
parent 8deeb10ef8
commit c70a46b8bf
@@ -196,7 +196,7 @@ class AccountPaymentTerm(models.Model):
#We sort by the last line of a term
term_lines = self.line_ids.sorted(lambda l: l == self.line_ids[-1])
last_percent_line = term_lines.filtered(lambda l: l.value == 'percent')[-1]
last_percent_line = term_lines.filtered(lambda l: l.value == 'percent')[-1:]
for line in self.line_ids.sorted(lambda l: l == self.line_ids[-1]):
term_vals = {
'date': line._get_due_date(date_ref),