diff --git a/beesdoo_shift_attendance/__manifest__.py b/beesdoo_shift_attendance/__manifest__.py index 21dd2f3..fa58261 100644 --- a/beesdoo_shift_attendance/__manifest__.py +++ b/beesdoo_shift_attendance/__manifest__.py @@ -11,7 +11,7 @@ "author": "Elouan Le Bars, Coop IT Easy SCRLfs", "website": "https://github.com/beescoop/Obeesdoo", "category": "Cooperative management", - "version": "12.0.1.0.1", + "version": "12.0.1.0.2", "depends": [ "beesdoo_base", "beesdoo_shift", diff --git a/beesdoo_shift_attendance/models/attendance_sheet.py b/beesdoo_shift_attendance/models/attendance_sheet.py index 9cfeca6..127f6d1 100644 --- a/beesdoo_shift_attendance/models/attendance_sheet.py +++ b/beesdoo_shift_attendance/models/attendance_sheet.py @@ -1,9 +1,14 @@ +import logging + from datetime import date, datetime, timedelta from odoo import _, api, fields, models from odoo.exceptions import UserError +_logger = logging.getLogger(__name__) + + class AttendanceSheetShift(models.Model): """ Partial copy of Task class to use in AttendanceSheet, @@ -472,6 +477,24 @@ class AttendanceSheet(models.Model): # Expected shifts status update for expected_shift in self.expected_shift_ids: actual_shift = expected_shift.task_id + if not actual_shift: + _logger.warning( + "The shift linked to the expected shift with id %s " + "for the partner id %s does not exist anymore." + "The expected shift is ignored during the validation " + "process of the attendance sheet." + % (expected_shift.id, expected_shift.worker_id.id) + ) + self._message_log( + body=_( + "The shift linked to the expected shift of %s " + "does exist any more." + "This expected shift is ignored in the " + "validation process." + % expected_shift.worker_id.name + ) + ) + continue actual_shift.replaced_id = expected_shift.replaced_id actual_shift.state = expected_shift.state