From 4fa6ed837bb84845465dc8e940e76f4da184b22a Mon Sep 17 00:00:00 2001 From: Mahamadasif Ansari Date: Fri, 7 Apr 2023 09:20:20 +0000 Subject: [PATCH] [FIX] account: assign current date in due_date if date_ref not available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unsupported operand type(s) for +: 'NoneType' and 'relativedelta' occur when we create payment terms without a preview date (date_ref). This is because date_ref has no value. This commit solves the issue by adding a condition if date_ref is not available, so it adds current date instead of it. sentry-4068322613 closes odoo/odoo#119187 X-original-commit: a9f556c0d45c32574c94765462d4b59726fc3f19 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 5fcbfdbd60e..3dccc01e8ee 100644 --- a/addons/account/models/account_payment_term.py +++ b/addons/account/models/account_payment_term.py @@ -263,7 +263,7 @@ class AccountPaymentTermLine(models.Model): def _get_due_date(self, date_ref): self.ensure_one() - due_date = fields.Date.from_string(date_ref) + due_date = fields.Date.from_string(date_ref) or fields.Date.today() if self.delay_type == 'days_after_end_of_month': return date_utils.end_of(due_date, 'month') + relativedelta(days=self.nb_days) elif self.delay_type == 'days_after_end_of_next_month':