diff --git a/addons/hr_holidays_attendance/data/hr_holidays_attendance_data.xml b/addons/hr_holidays_attendance/data/hr_holidays_attendance_data.xml
index 963a07053fa..7bcbded3984 100644
--- a/addons/hr_holidays_attendance/data/hr_holidays_attendance_data.xml
+++ b/addons/hr_holidays_attendance/data/hr_holidays_attendance_data.xml
@@ -10,5 +10,8 @@
+
+
+
diff --git a/addons/hr_holidays_attendance/models/res_company.py b/addons/hr_holidays_attendance/models/res_company.py
index 1e13e416b15..ce44045cdf3 100644
--- a/addons/hr_holidays_attendance/models/res_company.py
+++ b/addons/hr_holidays_attendance/models/res_company.py
@@ -1,19 +1,17 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-from odoo import models
+from odoo import api, models
class ResCompany(models.Model):
_inherit = 'res.company'
- def write(self, vals):
- res = super().write(vals)
- if 'hr_attendance_overtime' not in vals:
- return res
+ @api.model
+ def _check_extra_hours_time_off(self):
extra_hours_time_off_type = self.env.ref('hr_holidays_attendance.holiday_status_extra_hours', raise_if_not_found=False)
if not extra_hours_time_off_type:
- return res
+ return
all_companies = self.env['res.company'].sudo().search([])
# Unarchive time of type if the feature is enabled
if any(company.hr_attendance_overtime and not extra_hours_time_off_type.active for company in all_companies):
@@ -21,4 +19,9 @@ class ResCompany(models.Model):
# Archive time of type if the feature is disabled for all the company
if all(not company.hr_attendance_overtime and extra_hours_time_off_type.active for company in all_companies):
extra_hours_time_off_type.toggle_active()
+
+ def write(self, vals):
+ res = super().write(vals)
+ if 'hr_attendance_overtime' in vals:
+ self._check_extra_hours_time_off()
return res