diff --git a/yuthon_hr_attendance/models/overtime_approval.py b/yuthon_hr_attendance/models/overtime_approval.py index 3145c5fff..9f100599d 100644 --- a/yuthon_hr_attendance/models/overtime_approval.py +++ b/yuthon_hr_attendance/models/overtime_approval.py @@ -40,6 +40,8 @@ class OvertimeApprovals(models.Model): attendance_id = fields.Many2one('hr.attendance', string="当天考勤") start_week = fields.Char(string="星期", compute='_compute_weekday') end_time = fields.Datetime(string="结束时间") + start_time_cst = fields.Char(string="开始时间(北京)", compute='_compute_cst_times') + end_time_cst = fields.Char(string="结束时间(北京)", compute='_compute_cst_times') rest_start_time = fields.Datetime(string="休息开始时间") rest_end_time = fields.Datetime(string="休息结束时间") end_week = fields.Char(string="星期", compute='_compute_weekday') @@ -287,6 +289,14 @@ class OvertimeApprovals(models.Model): rec.duration = min(calculated_hours, max_hours) + @api.depends('start_time', 'end_time') + def _compute_cst_times(self): + """将UTC时间转换为北京时间(UTC+8)用于打印""" + offset = timedelta(hours=8) + for rec in self: + rec.start_time_cst = (rec.start_time + offset).strftime('%Y-%m-%d %H:%M') if rec.start_time else '' + rec.end_time_cst = (rec.end_time + offset).strftime('%Y-%m-%d %H:%M') if rec.end_time else '' + @api.depends('start_time', 'end_time') def _compute_weekday(self): weekday_names = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'] diff --git a/yuthon_hr_attendance/report/overtime_approval_templates.xml b/yuthon_hr_attendance/report/overtime_approval_templates.xml index 92331e36b..50ed8ecfd 100644 --- a/yuthon_hr_attendance/report/overtime_approval_templates.xml +++ b/yuthon_hr_attendance/report/overtime_approval_templates.xml @@ -59,8 +59,8 @@