From efc0ff463b9a63918e88bfa08fc447e5582ccb21 Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Thu, 23 Mar 2023 12:11:47 +0000 Subject: [PATCH] [FIX] hr_contract: do not close contracts a day early Steps to reproduce: Launch a contract which has an end date scheduled for the next day for an employee and manually activate the "HR Contract: update state" cron. Issue: Running contracts are closed one day in advance. Solution: Correct the condition which selects contracts to close. opw-3217616 closes odoo/odoo#116580 X-original-commit: e08aa67009b191cb99dfb1f7f1d0cb9d6539376a Signed-off-by: Kevin Baptiste Signed-off-by: Lefebvre Thomas (thle) --- addons/hr_contract/models/hr_contract.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/hr_contract/models/hr_contract.py b/addons/hr_contract/models/hr_contract.py index 9bf7b297f40..1ffd7ce81c2 100644 --- a/addons/hr_contract/models/hr_contract.py +++ b/addons/hr_contract/models/hr_contract.py @@ -185,8 +185,8 @@ class Contract(models.Model): contracts_to_close = self.search([ ('state', '=', 'open'), '|', - ('date_end', '<=', fields.Date.to_string(date.today() + relativedelta(days=1))), - ('visa_expire', '<=', fields.Date.to_string(date.today() + relativedelta(days=1))), + ('date_end', '<=', fields.Date.to_string(date.today())), + ('visa_expire', '<=', fields.Date.to_string(date.today())), ]) if contracts_to_close: