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 1/7] =?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 = "" From 8dfb1c28b48bb2b316db72db932ea4e5df7dba88 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 11:10:44 +0800 Subject: [PATCH 2/7] =?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 | 28 +++++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/yuthon_will_task/models/yuthon_will_task.py b/yuthon_will_task/models/yuthon_will_task.py index c4f39832c..50114e8d2 100644 --- a/yuthon_will_task/models/yuthon_will_task.py +++ b/yuthon_will_task/models/yuthon_will_task.py @@ -159,19 +159,31 @@ 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: - # 当类型为会议且关联了会议室预订时,拼接结束时间 - if record.task_type == 'meet' and record.room_booking_id: - # 获取会议室预订的结束时间(本地时间 UTC+8) - stop_datetime = record.room_booking_id.stop_datetime - if stop_datetime: + 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 # 转换为本地时间 + 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") - record.task_time = f"{date_str} {record.task_week} {from_time}-{stop_time_str}" + # 计算周几 + weekdays = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"] + week_str = weekdays[local_start.weekday()] + record.task_time = f"{start_date_str} {week_str} {start_time_str}-{stop_time_str}" else: - record.task_time = f"{date_str} {record.task_week} {from_time}" + # 没有关联会议室,使用日程的开始和结束时间 + 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}" else: + # 日程类型,只显示开始时间 record.task_time = f"{date_str} {record.task_week} {from_time}" else: record.task_time = "" From de63f2bfe9f379c33cfc8298ece816c3a536ad88 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 11:25:11 +0800 Subject: [PATCH 3/7] =?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 | 24 +++++++++++++++++++ .../views/yuthon_will_task_views.xml | 6 +++-- 2 files changed, 28 insertions(+), 2 deletions(-) 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"> - + + From d901e03c9b40d7b4a4a2f6a18959c5f51725e1a5 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 11:30:00 +0800 Subject: [PATCH 4/7] =?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/views/yuthon_will_task_views.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/yuthon_will_task/views/yuthon_will_task_views.xml b/yuthon_will_task/views/yuthon_will_task_views.xml index 336788ad8..d51183866 100644 --- a/yuthon_will_task/views/yuthon_will_task_views.xml +++ b/yuthon_will_task/views/yuthon_will_task_views.xml @@ -134,6 +134,7 @@ decoration-success="priority == 'important'" create="false" edit="false" js_class="custom_task_tree_button" limit="15"> + From d21845c23eca77f21ef24940eca22775effd9460 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 11:34:37 +0800 Subject: [PATCH 5/7] =?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 | 52 ++++----------------- 1 file changed, 8 insertions(+), 44 deletions(-) diff --git a/yuthon_will_task/models/yuthon_will_task.py b/yuthon_will_task/models/yuthon_will_task.py index c956d94f2..c4f39832c 100644 --- a/yuthon_will_task/models/yuthon_will_task.py +++ b/yuthon_will_task/models/yuthon_will_task.py @@ -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 = "" From 58cc45f8079490a3d0eae1fc440d024703889ddc 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 11:43:50 +0800 Subject: [PATCH 6/7] =?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 | 94 +++++++++---------- .../views/yuthon_will_task_views.xml | 7 +- 2 files changed, 48 insertions(+), 53 deletions(-) diff --git a/yuthon_will_task/models/yuthon_will_task.py b/yuthon_will_task/models/yuthon_will_task.py index c4f39832c..3b3f28838 100644 --- a/yuthon_will_task/models/yuthon_will_task.py +++ b/yuthon_will_task/models/yuthon_will_task.py @@ -125,56 +125,54 @@ class YuthonWillTask(models.Model): for record in will_ids: record._check_task_time() - @api.constrains('start_date', 'request_hour_from', 'request_hour_to', 'task_type', 'room_booking_id') + @api.constrains('start_date', 'request_hour_from', 'request_hour_to') def _check_task_time(self): for record in self: - date_str = "" - if record.start_date: - date_str = record.start_date.strftime("%Y/%m/%d") - hour_mapping = { - '0': '0:00', '0.25': '0:15', '0.5': '0:30', '0.75': '0:45', - '1': '01:00', '1.25': '01:15', '1.5': '01:30', '1.75': '01:45', - '2': '02:00', '2.25': '02:15', '2.5': '02:30', '2.75': '02:45', - '3': '03:00', '3.25': '03:15', '3.5': '03:30', '3.75': '03:45', - '4': '04:00', '4.25': '04:15', '4.5': '04:30', '4.75': '04:45', - '5': '05:00', '5.25': '05:15', '5.5': '05:30', '5.75': '05:45', - '6': '06:00', '6.25': '06:15', '6.5': '06:30', '6.75': '06:45', - '7': '07:00', '7.25': '07:15', '7.5': '07:30', '7.75': '07:45', - '8': '08:00', '8.25': '08:15', '8.5': '08:30', '8.75': '08:45', - '9': '09:00', '9.25': '09:15', '9.5': '09:30', '9.75': '09:45', - '10': '10:00', '10.25': '10:15', '10.5': '10:30', '10.75': '10:45', - '11': '11:00', '11.25': '11:15', '11.5': '11:30', '11.75': '11:45', - '12': '12:00', '12.25': '12:15', '12.5': '12:30', '12.75': '12:45', - '13': '13:00', '13.25': '13:15', '13.5': '13:30', '13.75': '13:45', - '14': '14:00', '14.25': '14:15', '14.5': '14:30', '14.75': '14:45', - '15': '15:00', '15.25': '15:15', '15.5': '15:30', '15.75': '15:45', - '16': '16:00', '16.25': '16:15', '16.5': '16:30', '16.75': '16:45', - '17': '17:00', '17.25': '17:15', '17.5': '17:30', '17.75': '17:45', - '18': '18:00', '18.25': '18:15', '18.5': '18:30', '18.75': '18:45', - '19': '19:00', '19.25': '19:15', '19.5': '19:30', '19.75': '19:45', - '20': '20:00', '20.25': '20:15', '20.5': '20:30', '20.75': '20:45', - '21': '21:00', '21.25': '21:15', '21.5': '21:30', '21.75': '21:45', - '22': '22:00', '22.25': '22:15', '22.5': '22:30', '22.75': '22:45', - '23': '23:00', '23.25': '23:15', '23.5': '23:30', '23.75': '23:45' - } - 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: - # 当类型为会议且关联了会议室预订时,拼接结束时间 - 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}" + record._compute_task_time_value() + + def _compute_task_time_value(self): + """计算并写入 task_time 字段""" + date_str = "" + if self.start_date: + date_str = self.start_date.strftime("%Y/%m/%d") + hour_mapping = { + '0': '0:00', '0.25': '0:15', '0.5': '0:30', '0.75': '0:45', + '1': '01:00', '1.25': '01:15', '1.5': '01:30', '1.75': '01:45', + '2': '02:00', '2.25': '02:15', '2.5': '02:30', '2.75': '02:45', + '3': '03:00', '3.25': '03:15', '3.5': '03:30', '3.75': '03:45', + '4': '04:00', '4.25': '04:15', '4.5': '04:30', '4.75': '04:45', + '5': '05:00', '5.25': '05:15', '5.5': '05:30', '5.75': '05:45', + '6': '06:00', '6.25': '06:15', '6.5': '06:30', '6.75': '06:45', + '7': '07:00', '7.25': '07:15', '7.5': '07:30', '7.75': '07:45', + '8': '08:00', '8.25': '08:15', '8.5': '08:30', '8.75': '08:45', + '9': '09:00', '9.25': '09:15', '9.5': '09:30', '9.75': '09:45', + '10': '10:00', '10.25': '10:15', '10.5': '10:30', '10.75': '10:45', + '11': '11:00', '11.25': '11:15', '11.5': '11:30', '11.75': '11:45', + '12': '12:00', '12.25': '12:15', '12.5': '12:30', '12.75': '12:45', + '13': '13:00', '13.25': '13:15', '13.5': '13:30', '13.75': '13:45', + '14': '14:00', '14.25': '14:15', '14.5': '14:30', '14.75': '14:45', + '15': '15:00', '15.25': '15:15', '15.5': '15:30', '15.75': '15:45', + '16': '16:00', '16.25': '16:15', '16.5': '16:30', '16.75': '16:45', + '17': '17:00', '17.25': '17:15', '17.5': '17:30', '17.75': '17:45', + '18': '18:00', '18.25': '18:15', '18.5': '18:30', '18.75': '18:45', + '19': '19:00', '19.25': '19:15', '19.5': '19:30', '19.75': '19:45', + '20': '20:00', '20.25': '20:15', '20.5': '20:30', '20.75': '20:45', + '21': '21:00', '21.25': '21:15', '21.5': '21:30', '21.75': '21:45', + '22': '22:00', '22.25': '22:15', '22.5': '22:30', '22.75': '22:45', + '23': '23:00', '23.25': '23:15', '23.5': '23:30', '23.75': '23:45' + } + from_time = hour_mapping.get(self.request_hour_from, "") + if date_str and from_time and self.task_week: + base_time = f"{date_str} {self.task_week} {from_time}" + # 会议类型:拼接结束时间 + if self.task_type == 'meet' and self.room_booking_id and self.room_booking_id.stop_datetime: + stop_local = self.room_booking_id.stop_datetime + timedelta(hours=8) + stop_str = stop_local.strftime("%H:%M") + self.task_time = f"{base_time}-{stop_str}" else: - record.task_time = "" + self.task_time = base_time + else: + self.task_time = "" @api.onchange('employee_ids', 'user_id') def _onchange_employee_ids(self): @@ -288,7 +286,7 @@ class YuthonWillTask(models.Model): def write(self, vals): """修改日程时,先删除旧提醒任务,再创建新的""" res = super(YuthonWillTask, self).write(vals) - key_fields = ['start_date', 'request_hour_from', 'task_time_ids', 'employee_ids', 'employee_ids2'] + key_fields = ['start_date', 'request_hour_from', 'task_time_ids', 'employee_ids', 'employee_ids2', 'task_type', 'room_booking_id'] if any(field in vals for field in key_fields): self._sync_dates_task() return res diff --git a/yuthon_will_task/views/yuthon_will_task_views.xml b/yuthon_will_task/views/yuthon_will_task_views.xml index d51183866..3bf830273 100644 --- a/yuthon_will_task/views/yuthon_will_task_views.xml +++ b/yuthon_will_task/views/yuthon_will_task_views.xml @@ -11,8 +11,7 @@ decoration-success="priority == 'important'" limit="15" action="open_record" type="object"> - - + @@ -134,9 +133,7 @@ decoration-success="priority == 'important'" create="false" edit="false" js_class="custom_task_tree_button" limit="15"> - - - + From b19c669009d8a1fd1290f6123f58480ba4ffb41a 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 11:49:30 +0800 Subject: [PATCH 7/7] =?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 | 80 +++++++++------------ 1 file changed, 35 insertions(+), 45 deletions(-) diff --git a/yuthon_will_task/models/yuthon_will_task.py b/yuthon_will_task/models/yuthon_will_task.py index 3b3f28838..dc6b04a78 100644 --- a/yuthon_will_task/models/yuthon_will_task.py +++ b/yuthon_will_task/models/yuthon_will_task.py @@ -128,51 +128,41 @@ class YuthonWillTask(models.Model): @api.constrains('start_date', 'request_hour_from', 'request_hour_to') def _check_task_time(self): for record in self: - record._compute_task_time_value() - - def _compute_task_time_value(self): - """计算并写入 task_time 字段""" - date_str = "" - if self.start_date: - date_str = self.start_date.strftime("%Y/%m/%d") - hour_mapping = { - '0': '0:00', '0.25': '0:15', '0.5': '0:30', '0.75': '0:45', - '1': '01:00', '1.25': '01:15', '1.5': '01:30', '1.75': '01:45', - '2': '02:00', '2.25': '02:15', '2.5': '02:30', '2.75': '02:45', - '3': '03:00', '3.25': '03:15', '3.5': '03:30', '3.75': '03:45', - '4': '04:00', '4.25': '04:15', '4.5': '04:30', '4.75': '04:45', - '5': '05:00', '5.25': '05:15', '5.5': '05:30', '5.75': '05:45', - '6': '06:00', '6.25': '06:15', '6.5': '06:30', '6.75': '06:45', - '7': '07:00', '7.25': '07:15', '7.5': '07:30', '7.75': '07:45', - '8': '08:00', '8.25': '08:15', '8.5': '08:30', '8.75': '08:45', - '9': '09:00', '9.25': '09:15', '9.5': '09:30', '9.75': '09:45', - '10': '10:00', '10.25': '10:15', '10.5': '10:30', '10.75': '10:45', - '11': '11:00', '11.25': '11:15', '11.5': '11:30', '11.75': '11:45', - '12': '12:00', '12.25': '12:15', '12.5': '12:30', '12.75': '12:45', - '13': '13:00', '13.25': '13:15', '13.5': '13:30', '13.75': '13:45', - '14': '14:00', '14.25': '14:15', '14.5': '14:30', '14.75': '14:45', - '15': '15:00', '15.25': '15:15', '15.5': '15:30', '15.75': '15:45', - '16': '16:00', '16.25': '16:15', '16.5': '16:30', '16.75': '16:45', - '17': '17:00', '17.25': '17:15', '17.5': '17:30', '17.75': '17:45', - '18': '18:00', '18.25': '18:15', '18.5': '18:30', '18.75': '18:45', - '19': '19:00', '19.25': '19:15', '19.5': '19:30', '19.75': '19:45', - '20': '20:00', '20.25': '20:15', '20.5': '20:30', '20.75': '20:45', - '21': '21:00', '21.25': '21:15', '21.5': '21:30', '21.75': '21:45', - '22': '22:00', '22.25': '22:15', '22.5': '22:30', '22.75': '22:45', - '23': '23:00', '23.25': '23:15', '23.5': '23:30', '23.75': '23:45' - } - from_time = hour_mapping.get(self.request_hour_from, "") - if date_str and from_time and self.task_week: - base_time = f"{date_str} {self.task_week} {from_time}" - # 会议类型:拼接结束时间 - if self.task_type == 'meet' and self.room_booking_id and self.room_booking_id.stop_datetime: - stop_local = self.room_booking_id.stop_datetime + timedelta(hours=8) - stop_str = stop_local.strftime("%H:%M") - self.task_time = f"{base_time}-{stop_str}" + date_str = "" + if record.start_date: + date_str = record.start_date.strftime("%Y/%m/%d") + hour_mapping = { + '0': '0:00', '0.25': '0:15', '0.5': '0:30', '0.75': '0:45', + '1': '01:00', '1.25': '01:15', '1.5': '01:30', '1.75': '01:45', + '2': '02:00', '2.25': '02:15', '2.5': '02:30', '2.75': '02:45', + '3': '03:00', '3.25': '03:15', '3.5': '03:30', '3.75': '03:45', + '4': '04:00', '4.25': '04:15', '4.5': '04:30', '4.75': '04:45', + '5': '05:00', '5.25': '05:15', '5.5': '05:30', '5.75': '05:45', + '6': '06:00', '6.25': '06:15', '6.5': '06:30', '6.75': '06:45', + '7': '07:00', '7.25': '07:15', '7.5': '07:30', '7.75': '07:45', + '8': '08:00', '8.25': '08:15', '8.5': '08:30', '8.75': '08:45', + '9': '09:00', '9.25': '09:15', '9.5': '09:30', '9.75': '09:45', + '10': '10:00', '10.25': '10:15', '10.5': '10:30', '10.75': '10:45', + '11': '11:00', '11.25': '11:15', '11.5': '11:30', '11.75': '11:45', + '12': '12:00', '12.25': '12:15', '12.5': '12:30', '12.75': '12:45', + '13': '13:00', '13.25': '13:15', '13.5': '13:30', '13.75': '13:45', + '14': '14:00', '14.25': '14:15', '14.5': '14:30', '14.75': '14:45', + '15': '15:00', '15.25': '15:15', '15.5': '15:30', '15.75': '15:45', + '16': '16:00', '16.25': '16:15', '16.5': '16:30', '16.75': '16:45', + '17': '17:00', '17.25': '17:15', '17.5': '17:30', '17.75': '17:45', + '18': '18:00', '18.25': '18:15', '18.5': '18:30', '18.75': '18:45', + '19': '19:00', '19.25': '19:15', '19.5': '19:30', '19.75': '19:45', + '20': '20:00', '20.25': '20:15', '20.5': '20:30', '20.75': '20:45', + '21': '21:00', '21.25': '21:15', '21.5': '21:30', '21.75': '21:45', + '22': '22:00', '22.25': '22:15', '22.5': '22:30', '22.75': '22:45', + '23': '23:00', '23.25': '23:15', '23.5': '23:30', '23.75': '23:45' + } + 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}" else: - self.task_time = base_time - else: - self.task_time = "" + record.task_time = "" @api.onchange('employee_ids', 'user_id') def _onchange_employee_ids(self): @@ -286,7 +276,7 @@ class YuthonWillTask(models.Model): def write(self, vals): """修改日程时,先删除旧提醒任务,再创建新的""" res = super(YuthonWillTask, self).write(vals) - key_fields = ['start_date', 'request_hour_from', 'task_time_ids', 'employee_ids', 'employee_ids2', 'task_type', 'room_booking_id'] + key_fields = ['start_date', 'request_hour_from', 'task_time_ids', 'employee_ids', 'employee_ids2'] if any(field in vals for field in key_fields): self._sync_dates_task() return res