日程管理

This commit is contained in:
李鹏宇
2026-03-09 10:47:33 +08:00
parent 67baa4ed03
commit 3aecbfca22
+14 -2
View File
@@ -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 = ""