From 77a5dfd120277fbba3cf368e6ae47f06635c3237 Mon Sep 17 00:00:00 2001
From: Philippe Wauthy <phwa@odoo.com>
Date: Mon, 3 Jan 2022 09:32:25 +0000
Subject: [PATCH] [FIX] hr_holidays: fix test_leave_whole_company_07 test

test_leave_whole_company_07 test was failing due ot the hr_leave_date_check2
constraint.
This constraint check that date_from <= date_to for a leave.

date_from and date_to were not assigned any value before and had a default value
of fields.Datetime.now. Depending on which date_from or date_to is created first,
a few second difference can exist and this violates the hr_leave_date_check2 constraint

task-2726143

closes odoo/odoo#82131

Signed-off-by: Kevin Baptiste <kba@odoo.com>
---
 addons/hr_holidays/tests/test_company_leave.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/addons/hr_holidays/tests/test_company_leave.py b/addons/hr_holidays/tests/test_company_leave.py
index b922b2b569fc..8c03a4446c8a 100644
--- a/addons/hr_holidays/tests/test_company_leave.py
+++ b/addons/hr_holidays/tests/test_company_leave.py
@@ -295,7 +295,9 @@ class TestCompanyLeave(SavepointCase):
             'employee_id': employee.id,
             'holiday_status_id': self.paid_time_off.id,
             'request_date_from': date(2020, 3, 29),
+            'date_from': datetime(2020, 3, 29, 7, 0, 0),
             'request_date_to': date(2020, 4, 1),
+            'date_to': datetime(2020, 4, 1, 19, 0, 0),
             'number_of_days': 3,
         } for employee in employees[0:15]])
         for leave in leaves:
-- 
GitLab