diff options
| author | Swapnesh Shah <swapneshshah111@gmail.com> | 2020-05-17 14:06:32 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-11 14:58:06 +0000 |
| commit | 8f8ec48f857bf9f47b67c176efb3d54b16f3a371 (patch) | |
| tree | 07eed508fa18746214a0b6b73577cb344239e159 /addons/hr_attendance | |
| parent | 1b62bd9508c58c5a4f2e41f2176d737a2e404656 (diff) | |
[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.
X-original-commit: b1bc2ba4a986bf7bce242496f822f9891937c9cf
Diffstat (limited to 'addons/hr_attendance')
| -rw-r--r-- | addons/hr_attendance/models/hr_attendance.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/addons/hr_attendance/models/hr_attendance.py b/addons/hr_attendance/models/hr_attendance.py index 87435cfabc8..c14adf39ece 100644 --- a/addons/hr_attendance/models/hr_attendance.py +++ b/addons/hr_attendance/models/hr_attendance.py @@ -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) |
