From b59d94bcc1769481073244b6f092c7a434b6d6b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Fri, 10 Apr 2026 11:19:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_hr_attendance/models/overtime_approval.py | 10 ++++++++++ .../report/overtime_approval_templates.xml | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) 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 @@ 时间 - 至 - , + 至 + , 时长 小时