@@ -86,7 +86,6 @@ class YuthonWillTask(models.Model):
|
||||
('meet', '会议')
|
||||
], string='类型', default='task')
|
||||
room_booking_id = fields.Many2one('room.booking', string='会议室')
|
||||
meeting_time = fields.Char(string='会议时间', compute='_compute_meeting_time')
|
||||
|
||||
def back_wecom_msg(self):
|
||||
self.env['wecom.apps'].back_message(category='task', msg_id=self.msg_id)
|
||||
@@ -126,29 +125,6 @@ class YuthonWillTask(models.Model):
|
||||
for record in will_ids:
|
||||
record._check_task_time()
|
||||
|
||||
@api.depends('room_booking_id', 'room_booking_id.start_datetime', 'room_booking_id.stop_datetime')
|
||||
def _compute_meeting_time(self):
|
||||
for record in self:
|
||||
if record.room_booking_id and record.room_booking_id.start_datetime:
|
||||
# 显示会议室的日期时间范围
|
||||
start_dt = record.room_booking_id.start_datetime
|
||||
stop_dt = record.room_booking_id.stop_datetime
|
||||
# 转换为本地时间(UTC+8)
|
||||
local_start = start_dt + timedelta(hours=8)
|
||||
start_date_str = local_start.strftime("%Y/%m/%d")
|
||||
start_time_str = local_start.strftime("%H:%M")
|
||||
# 计算周几
|
||||
weekdays = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]
|
||||
week_str = weekdays[local_start.weekday()]
|
||||
if stop_dt:
|
||||
local_stop = stop_dt + timedelta(hours=8)
|
||||
stop_time_str = local_stop.strftime("%H:%M")
|
||||
record.meeting_time = f"{start_date_str} {week_str} {start_time_str}-{stop_time_str}"
|
||||
else:
|
||||
record.meeting_time = f"{start_date_str} {week_str} {start_time_str}"
|
||||
else:
|
||||
record.meeting_time = ""
|
||||
|
||||
@api.constrains('start_date', 'request_hour_from', 'request_hour_to', 'task_type', 'room_booking_id')
|
||||
def _check_task_time(self):
|
||||
for record in self:
|
||||
@@ -183,31 +159,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:
|
||||
# 当类型为会议时,显示开始时间和结束时间
|
||||
if record.task_type == 'meet':
|
||||
if record.room_booking_id and record.room_booking_id.start_datetime and record.room_booking_id.stop_datetime:
|
||||
# 有关联会议室预订,使用会议室的时间
|
||||
start_datetime = record.room_booking_id.start_datetime
|
||||
stop_datetime = record.room_booking_id.stop_datetime
|
||||
if date_str and from_time and to_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_start = start_datetime + timedelta(hours=8)
|
||||
local_stop = stop_datetime + timedelta(hours=8)
|
||||
start_date_str = local_start.strftime("%Y/%m/%d")
|
||||
start_time_str = local_start.strftime("%H:%M")
|
||||
stop_time_str = local_stop.strftime("%H:%M")
|
||||
# 计算周几
|
||||
weekdays = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]
|
||||
week_str = weekdays[local_start.weekday()]
|
||||
record.task_time = f"{start_date_str} {week_str} {start_time_str}-{stop_time_str}"
|
||||
record.task_time = f"{date_str} {record.task_week} {from_time}-{stop_time_str}"
|
||||
else:
|
||||
# 没有关联会议室,使用日程的开始和结束时间
|
||||
if to_time:
|
||||
record.task_time = f"{date_str} {record.task_week} {from_time}-{to_time}"
|
||||
else:
|
||||
record.task_time = f"{date_str} {record.task_week} {from_time}"
|
||||
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 = ""
|
||||
|
||||
Reference in New Issue
Block a user