diff options
| -rw-r--r-- | addons/hr_payroll/models/hr_payslip.py | 3 | ||||
| -rw-r--r-- | addons/resource/models/resource_mixin.py | 6 |
2 files changed, 6 insertions, 3 deletions
diff --git a/addons/hr_payroll/models/hr_payslip.py b/addons/hr_payroll/models/hr_payslip.py index 726e5efe375..c9d14c47495 100644 --- a/addons/hr_payroll/models/hr_payslip.py +++ b/addons/hr_payroll/models/hr_payslip.py @@ -190,7 +190,8 @@ class HrPayslip(models.Model): leave_time = (interval[1] - interval[0]).seconds / 3600 current_leave_struct['number_of_hours'] += leave_time work_hours = contract.employee_id.get_day_work_hours_count(interval[0].date(), calendar=contract.resource_calendar_id) - current_leave_struct['number_of_days'] += leave_time / work_hours + if work_hours: + current_leave_struct['number_of_days'] += leave_time / work_hours # compute worked days work_data = contract.employee_id.get_work_days_data(day_from, day_to, calendar=contract.resource_calendar_id) diff --git a/addons/resource/models/resource_mixin.py b/addons/resource/models/resource_mixin.py index fd531467998..fcee4086ca3 100644 --- a/addons/resource/models/resource_mixin.py +++ b/addons/resource/models/resource_mixin.py @@ -57,7 +57,8 @@ class ResourceMixin(models.AbstractModel): theoric_hours = self.get_day_work_hours_count(day_intervals[0][0].date(), calendar=calendar) work_time = sum((interval[1] - interval[0] for interval in day_intervals), timedelta()) total_work_time += work_time - days_count += float_utils.round((work_time.total_seconds() / 3600 / theoric_hours) * 4) / 4 + if theoric_hours: + days_count += float_utils.round((work_time.total_seconds() / 3600 / theoric_hours) * 4) / 4 return { 'days': days_count, 'hours': total_work_time.total_seconds() / 3600, @@ -80,7 +81,8 @@ class ResourceMixin(models.AbstractModel): for day_intervals in calendar._iter_leave_intervals(from_datetime, to_datetime, self.resource_id.id): theoric_hours = self.get_day_work_hours_count(day_intervals[0][0].date(), calendar=calendar) leave_time = sum((interval[1] - interval[0] for interval in day_intervals), timedelta()) - days_count += float_utils.round((leave_time.total_seconds() / 3600 / theoric_hours) * 4) / 4 + if theoric_hours: + days_count += float_utils.round((leave_time.total_seconds() / 3600 / theoric_hours) * 4) / 4 return days_count def iter_leaves(self, from_datetime, to_datetime, calendar=None): |
