diff --git a/hr-luncheon-voucher/__manifest__.py b/hr-luncheon-voucher/__manifest__.py index 79174ed..675e9f4 100755 --- a/hr-luncheon-voucher/__manifest__.py +++ b/hr-luncheon-voucher/__manifest__.py @@ -2,7 +2,7 @@ { "name": "HR Luncheon Voucher", "category": "Human Resources", - "version": "14.0.1.2.0", + "version": "14.0.2.0.0", "summary": "Manage luncheon vouchers credit and distribution", "author": "Elabore", "website": "https://elabore.coop/", diff --git a/hr-luncheon-voucher/models/__init__.py b/hr-luncheon-voucher/models/__init__.py index af55a20..aefe482 100644 --- a/hr-luncheon-voucher/models/__init__.py +++ b/hr-luncheon-voucher/models/__init__.py @@ -3,6 +3,5 @@ from . import calendar_event_type from . import hr_employee from . import hr_lv_allocation -from . import resource from . import res_company from . import res_config_settings diff --git a/hr-luncheon-voucher/models/resource.py b/hr-luncheon-voucher/models/resource.py deleted file mode 100644 index f55451f..0000000 --- a/hr-luncheon-voucher/models/resource.py +++ /dev/null @@ -1,63 +0,0 @@ -from datetime import timedelta -import math -from odoo import models, fields - - -class ResourceCalendar(models.Model): - _inherit = "resource.calendar" - - def _retrieve_day_matching_attendances(self, day): - domain = [ - ("calendar_id", "=", self.id), - ("dayofweek", "=", day.weekday()), - ("effective_attendance_period", "=", True) - ] - if self.two_weeks_calendar: - # Employee has Even/Odd weekly calendar - week_type = 1 if int(math.floor((day.toordinal() - 1) / 7) % 2) else 0 - domain.append(("week_type", "=", week_type)) - result = self.env["resource.calendar.attendance"].search(domain) - return result - - def is_working_day(self, day): - day_attendances = self._retrieve_day_matching_attendances(day) - if len(day_attendances) == 0: - # This day of the week is not supposed to be a working day - return False - else: - # This day of the week is supposed to be a working day - return True - - def is_full_working_day(self, day): - day_attendances = self._retrieve_day_matching_attendances(day) - morning_worked = len(day_attendances.filtered(lambda x: x.day_period == "morning")) > 0 - afternoon_worked = len(day_attendances.filtered(lambda x: x.day_period == "afternoon")) > 0 - return morning_worked and afternoon_worked - - - def _is_worked_attendance(self, resource, day, attendance): - attendance_start = fields.Datetime.to_datetime(day.date()) + timedelta(hours=attendance.hour_from) - attendance_end = fields.Datetime.to_datetime(day.date()) + timedelta(hours=attendance.hour_to) - resource_leaves = self.env["resource.calendar.leaves"].search([("resource_id", "=", resource.id), ("date_from", "<=", attendance_start), ("date_to", ">=", attendance_end)]) - if resource_leaves: - return False - else: - # a part or the whole attendance is worked - return True - - def is_worked_day(self, resource, day): - day_attendances = self._retrieve_day_matching_attendances(day) - # If at least one attendance is worked, return True - for attendance in day_attendances: - if self._is_worked_attendance(resource, day, attendance): - return True - return False - - def all_attendances_worked(self, resource, day): - day_attendances = self._retrieve_day_matching_attendances(day) - # If at least one attendance is not worked, return False - for attendance in day_attendances: - if not self._is_worked_attendance(resource, day, attendance): - return False - return True -