From a28dca7b9deca8d1f20d8793c3bfda567ebfe059 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 21:24:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=9A=E8=AE=AE=E5=90=8C=E6=AD=A5=E6=97=A5?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/inherit_room_booking.py | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/yuthon_will_task/models/inherit_room_booking.py b/yuthon_will_task/models/inherit_room_booking.py index 06ecf11b9..bf18ef0a9 100644 --- a/yuthon_will_task/models/inherit_room_booking.py +++ b/yuthon_will_task/models/inherit_room_booking.py @@ -61,21 +61,22 @@ class InheritRoomBooking(models.Model): elif nearest_minute == 45: return f"{hour % 24}.75" - start_datetime = new_record.start_datetime - start_date = start_datetime.date() - request_hour_from = get_hour_selection(new_record.start_datetime) - request_hour_to = get_hour_selection(new_record.stop_datetime) - self.env['yuthon.will.task'].sudo().create({ - 'name': new_record.name, - 'users_ids': [(6, 0, new_record.room_users_ids.ids)], - 'employee_ids': [(6, 0, employee_list)], - 'task_time_ids': [(6, 0, task_time_ids.ids)] if task_time_ids else [(5, 0, 0)], - 'start_date': start_date, - 'request_hour_from': request_hour_from, - 'request_hour_to': request_hour_to, - 'address': new_record.room_id.name, - 'room_booking_id': new_record.id, - 'task_type': 'meet', - 'task_state': 'will', - }) + if task_time_ids: + start_datetime = new_record.start_datetime + start_date = start_datetime.date() + request_hour_from = get_hour_selection(new_record.start_datetime) + request_hour_to = get_hour_selection(new_record.stop_datetime) + self.env['yuthon.will.task'].sudo().create({ + 'name': new_record.name, + 'users_ids': [(6, 0, new_record.room_users_ids.ids)], + 'employee_ids': [(6, 0, employee_list)], + 'task_time_ids': [(6, 0, task_time_ids.ids)], + 'start_date': start_date, + 'request_hour_from': request_hour_from, + 'request_hour_to': request_hour_to, + 'address': new_record.room_id.name, + 'room_booking_id': new_record.id, + 'task_type': 'meet', + 'task_state': 'will', + }) return new_record