diff --git a/addons/hr_payroll/models/resource.py b/addons/hr_payroll/models/resource.py
index 440820f2017..6a68ed1b395 100644
--- a/addons/hr_payroll/models/resource.py
+++ b/addons/hr_payroll/models/resource.py
@@ -1,6 +1,6 @@
# -*- coding:utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-from odoo import models, fields
+from odoo import models, fields, api
from odoo.osv.expression import AND, OR
@@ -16,6 +16,15 @@ class ResourceCalendar(models.Model):
'resource.calendar.attendance', 'calendar_id', 'Employees working Time',
domain=[('resource_id', '!=', False)])
+ def _get_global_attendances(self):
+ res = super(ResourceCalendar, self)._get_global_attendances()
+ res |= self.normal_attendance_ids.filtered(lambda attendance: not attendance.date_from and not attendance.date_to)
+ return res
+
+ # Add a key on the api.onchange decorator
+ @api.onchange('attendance_ids', 'normal_attendance_ids')
+ def _onchange_hours_per_day(self):
+ return super(ResourceCalendar, self)._onchange_hours_per_day()
class ResourceCalendarAttendance(models.Model):
_inherit = 'resource.calendar.attendance'
diff --git a/addons/hr_payroll/views/resource_views.xml b/addons/hr_payroll/views/resource_views.xml
index 5fe67b67128..831e2206613 100644
--- a/addons/hr_payroll/views/resource_views.xml
+++ b/addons/hr_payroll/views/resource_views.xml
@@ -7,7 +7,10 @@
resource.calendar
-
+
+ 1
+
+
diff --git a/addons/resource/models/resource.py b/addons/resource/models/resource.py
index 481cb9b57df..b16c121799b 100644
--- a/addons/resource/models/resource.py
+++ b/addons/resource/models/resource.py
@@ -186,9 +186,13 @@ class ResourceCalendar(models.Model):
default=lambda self: self._context.get('tz') or self.env.user.tz or 'UTC',
help="This field is used in order to define in which timezone the resources will work.")
+
+ def _get_global_attendances(self):
+ return self.attendance_ids.filtered(lambda attendance: not attendance.date_from and not attendance.date_to and not attendance.resource_id)
+
@api.onchange('attendance_ids')
def _onchange_hours_per_day(self):
- attendances = self.attendance_ids.filtered(lambda attendance: not attendance.date_from and not attendance.date_to)
+ attendances = self._get_global_attendances()
hour_count = 0.0
for attendance in attendances:
hour_count += attendance.hour_to - attendance.hour_from