日程管理

This commit is contained in:
李鹏宇
2026-03-09 14:40:11 +08:00
parent aadcb4a09e
commit fe57f974fc
+10 -6
View File
@@ -125,7 +125,7 @@ class YuthonWillTask(models.Model):
for record in will_ids:
record._compute_task_time()
@api.depends('start_date', 'task_week', 'request_hour_from', 'task_type', 'room_booking_id', 'room_booking_id.stop_datetime')
@api.depends('start_date', 'task_week', 'request_hour_from', 'task_type', 'room_booking_id', 'room_booking_id.start_datetime', 'room_booking_id.stop_datetime')
def _compute_task_time(self):
for record in self:
date_str = ""
@@ -159,13 +159,17 @@ class YuthonWillTask(models.Model):
}
from_time = hour_mapping.get(record.request_hour_from, "")
if date_str and from_time:
base_time = f"{date_str} {record.task_week} {from_time}"
# 会议类型:拼接会议室预订的结束时间
if record.task_type == 'meet' and record.room_booking_id and record.room_booking_id.stop_datetime:
# 会议类型:显示完整的开始和结束日期时间
if record.task_type == 'meet' and record.room_booking_id and record.room_booking_id.start_datetime and record.room_booking_id.stop_datetime:
# 转换为本地时间(UTC+8)
start_local = record.room_booking_id.start_datetime + timedelta(hours=8)
stop_local = record.room_booking_id.stop_datetime + timedelta(hours=8)
stop_str = stop_local.strftime("%H:%M")
record.task_time = f"{base_time}-{stop_str}"
# 格式化为 "YYYY-M-D HH∶MM" 格式
start_str = start_local.strftime("%Y-%m-%d %H∶%M")
stop_str = stop_local.strftime("%Y-%m-%d %H∶%M")
record.task_time = f"{start_str} {stop_str}"
else:
base_time = f"{date_str} {record.task_week} {from_time}"
record.task_time = base_time
else:
record.task_time = ""