From 24f377b0ee6194ef45bb2ee8707ef11e83356ad5 Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Mon, 24 Jul 2023 07:52:58 +0000 Subject: [PATCH] [FIX] hr_holidays: remove time off type if no employee_id Steps to reproduce: ------------------- - go to the hr leave form; - select "By Employee" mode; - select an employee-based leave type; (example: Paid Time Off (20 remaining out of 20 days)) - change mode with "By Company"; Issue: ------ A specific leave to one employee can be validated for all employees of a company. Cause: ------ The `_compute_from_employee_id` method does not set the `holiday_status_id` field to `False` in this case. Solution: --------- When we detect an `employee_id` change and it is `False`, we must remove the current `holiday_status_id`. opw-3386332 closes odoo/odoo#129653 X-original-commit: a7a8e78103962844d7d3752d41f9ca4b22165569 Signed-off-by: Sofie Gvaladze (sgv) Signed-off-by: Thomas Lefebvre (thle) --- addons/hr_holidays/models/hr_leave.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_holidays/models/hr_leave.py b/addons/hr_holidays/models/hr_leave.py index 1b2cae9125c..a3b6ecc5fd9 100644 --- a/addons/hr_holidays/models/hr_leave.py +++ b/addons/hr_holidays/models/hr_leave.py @@ -455,7 +455,7 @@ class HolidaysRequest(models.Model): holiday.manager_id = holiday.employee_id.parent_id.id if holiday.holiday_status_id.requires_allocation == 'no': continue - if len(holiday.employee_ids) > 1: + if not holiday.employee_id or len(holiday.employee_ids) > 1: holiday.holiday_status_id = False elif holiday.employee_id.user_id != self.env.user and holiday._origin.employee_id != holiday.employee_id: if holiday.employee_id and not holiday.holiday_status_id.with_context(employee_id=holiday.employee_id.id).has_valid_allocation: