From 3aecbfca22aaeea6b446545fde8bb9bfbe9e2eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Mon, 9 Mar 2026 10:47:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E7=A8=8B=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_will_task/models/yuthon_will_task.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/yuthon_will_task/models/yuthon_will_task.py b/yuthon_will_task/models/yuthon_will_task.py index dc6b04a78..c4f39832c 100644 --- a/yuthon_will_task/models/yuthon_will_task.py +++ b/yuthon_will_task/models/yuthon_will_task.py @@ -125,7 +125,7 @@ class YuthonWillTask(models.Model): for record in will_ids: record._check_task_time() - @api.constrains('start_date', 'request_hour_from', 'request_hour_to') + @api.constrains('start_date', 'request_hour_from', 'request_hour_to', 'task_type', 'room_booking_id') def _check_task_time(self): for record in self: date_str = "" @@ -160,7 +160,19 @@ class YuthonWillTask(models.Model): from_time = hour_mapping.get(record.request_hour_from, "") to_time = hour_mapping.get(record.request_hour_to, "") if date_str and from_time and to_time: - record.task_time = f"{date_str} {record.task_week} {from_time}" + # 当类型为会议且关联了会议室预订时,拼接结束时间 + if record.task_type == 'meet' and record.room_booking_id: + # 获取会议室预订的结束时间(本地时间 UTC+8) + stop_datetime = record.room_booking_id.stop_datetime + if stop_datetime: + # 转换为本地时间 + local_stop = stop_datetime + timedelta(hours=8) + stop_time_str = local_stop.strftime("%H:%M") + record.task_time = f"{date_str} {record.task_week} {from_time}-{stop_time_str}" + else: + record.task_time = f"{date_str} {record.task_week} {from_time}" + else: + record.task_time = f"{date_str} {record.task_week} {from_time}" else: record.task_time = ""