From a3c2f04f68b9b545a06ac660bcedb2aa991a06f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= <9664676+pengyuthon@user.noreply.gitee.com> Date: Mon, 2 Feb 2026 10:16:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_hr_attendance/models/overtime_approval.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yuthon_hr_attendance/models/overtime_approval.py b/yuthon_hr_attendance/models/overtime_approval.py index 94beebc68..c51f7b59a 100644 --- a/yuthon_hr_attendance/models/overtime_approval.py +++ b/yuthon_hr_attendance/models/overtime_approval.py @@ -167,13 +167,13 @@ class OvertimeApprovals(models.Model): corrected_end_time = max_allowed_end_time - timedelta(hours=8) rec.end_time = corrected_end_time - @api.depends('users_id', 'duration') + @api.depends('users_id', 'duration', 'start_time') def _compute_overtime_hours(self): for rec in self: rec.overtime_hours = 0.0 - if not rec.users_id: + if not rec.users_id or not rec.start_time: continue - now = datetime.now() # 获取当前时间(datetime类型) + now = rec.start_time # 获取当前时间(datetime类型) first_datetime = datetime(now.year, now.month, 1, 0, 0, 0) if now.month == 12: next_month_datetime = datetime(now.year + 1, 1, 1, 0, 0, 0)