diff --git a/yuthon_will_task/models/yuthon_will_task.py b/yuthon_will_task/models/yuthon_will_task.py index 50114e8d2..c956d94f2 100644 --- a/yuthon_will_task/models/yuthon_will_task.py +++ b/yuthon_will_task/models/yuthon_will_task.py @@ -86,6 +86,7 @@ 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) @@ -125,6 +126,29 @@ 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: diff --git a/yuthon_will_task/views/yuthon_will_task_views.xml b/yuthon_will_task/views/yuthon_will_task_views.xml index 3bf830273..336788ad8 100644 --- a/yuthon_will_task/views/yuthon_will_task_views.xml +++ b/yuthon_will_task/views/yuthon_will_task_views.xml @@ -11,7 +11,8 @@ decoration-success="priority == 'important'" limit="15" action="open_record" type="object"> - + + @@ -133,7 +134,8 @@ decoration-success="priority == 'important'" create="false" edit="false" js_class="custom_task_tree_button" limit="15"> - + +