!10686 !10685 Merge branch 'dev' of <a href="https://gitee.com/jinan-pengyuse…

Merge pull request !10686 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2026-04-10 03:20:28 +00:00
committed by Gitee
2 changed files with 12 additions and 2 deletions
@@ -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 = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
@@ -59,8 +59,8 @@
<tr>
<td class="hdr" style="text-align:center;">时间</td>
<td colspan="2" class="cell-content">
<span t-esc="doc.start_time and doc.start_time.strftime('%Y-%m-%d %H:%M') or ''"/> 至
<span t-esc="doc.end_time and doc.end_time.strftime('%Y-%m-%d %H:%M') or ''"/>,
<span t-esc="doc.start_time_cst or ''"/> 至
<span t-esc="doc.end_time_cst or ''"/>,
时长 <span t-esc="doc.duration or 0.0"/> 小时
</td>
</tr>