From c70a46b8bfeb51ba1837cf779fae3ff01f72e570 Mon Sep 17 00:00:00 2001 From: Renilkumar Kajavadra Date: Fri, 14 Apr 2023 13:12:11 +0000 Subject: [PATCH] [FIX] account: fix IndexError in payment terms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- addons/account/models/account_payment_term.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/account_payment_term.py b/addons/account/models/account_payment_term.py index b1a543e3d68..5fcbfdbd60e 100644 --- a/addons/account/models/account_payment_term.py +++ b/addons/account/models/account_payment_term.py @@ -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),