Skip to content
Snippets Groups Projects
Commit b1bc2ba4 authored by Swapnesh Shah's avatar Swapnesh Shah Committed by GitHub
Browse files

[FIX] hr_attendance: correct datetime format on warning

Before this Commit, Datetime on warning was not formatted based on User's lang.

With this commit, we use `format_datetime` to correctly format Datetime.
parent 5f76782c
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, fields, api, exceptions, _
from odoo.tools import format_datetime
class HrAttendance(models.Model):
......@@ -69,7 +70,7 @@ class HrAttendance(models.Model):
if last_attendance_before_check_in and last_attendance_before_check_in.check_out and last_attendance_before_check_in.check_out > attendance.check_in:
raise exceptions.ValidationError(_("Cannot create new attendance record for %(empl_name)s, the employee was already checked in on %(datetime)s") % {
'empl_name': attendance.employee_id.name,
'datetime': fields.Datetime.to_string(fields.Datetime.context_timestamp(self, fields.Datetime.from_string(attendance.check_in))),
'datetime': format_datetime(self.env, attendance.check_in, dt_format=False),
})
if not attendance.check_out:
......@@ -82,7 +83,7 @@ class HrAttendance(models.Model):
if no_check_out_attendances:
raise exceptions.ValidationError(_("Cannot create new attendance record for %(empl_name)s, the employee hasn't checked out since %(datetime)s") % {
'empl_name': attendance.employee_id.name,
'datetime': fields.Datetime.to_string(fields.Datetime.context_timestamp(self, fields.Datetime.from_string(no_check_out_attendances.check_in))),
'datetime': format_datetime(self.env, no_check_out_attendances.check_in, dt_format=False),
})
else:
# we verify that the latest attendance with check_in time before our check_out time
......@@ -95,7 +96,7 @@ class HrAttendance(models.Model):
if last_attendance_before_check_out and last_attendance_before_check_in != last_attendance_before_check_out:
raise exceptions.ValidationError(_("Cannot create new attendance record for %(empl_name)s, the employee was already checked in on %(datetime)s") % {
'empl_name': attendance.employee_id.name,
'datetime': fields.Datetime.to_string(fields.Datetime.context_timestamp(self, fields.Datetime.from_string(last_attendance_before_check_out.check_in))),
'datetime': format_datetime(self.env, last_attendance_before_check_out.check_in, dt_format=False),
})
@api.returns('self', lambda value: value.id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment