Skip to content

Commit

Permalink
raise AccessError if no employee is found for current user
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardoalso committed Jul 16, 2024
1 parent 00f87c8 commit 7073aea
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hr_attendance_overtime/models/hr_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from dateutil.relativedelta import relativedelta
from pytz import timezone, utc

from odoo import SUPERUSER_ID, api, fields, models
from odoo import SUPERUSER_ID, _, api, fields, models
from odoo.exceptions import AccessError
from odoo.osv import expression


Expand All @@ -17,6 +18,9 @@ def todays_working_times(self, empl_domain):
"""Method used by my attendance/kiosk view in order
to display employee planning and working times"""
employee = self.search(empl_domain)
if not employee:
raise AccessError(_("Employee not found or not created for current user"))

Check warning on line 22 in hr_attendance_overtime/models/hr_employee.py

View check run for this annotation

Codecov / codecov/patch

hr_attendance_overtime/models/hr_employee.py#L22

Added line #L22 was not covered by tests

employee.ensure_one()
now = fields.Datetime.now()
tz = timezone(employee.tz)
Expand Down

0 comments on commit 7073aea

Please sign in to comment.