Files
gzth/yuthon_will_task/models/inherit_room_booking.py
T
2025-06-10 10:37:14 +08:00

29 lines
1.1 KiB
Python

from odoo import api, fields, models
class InheritRoomBooking(models.Model):
_inherit = 'room.booking'
@api.model
def create(self, vals):
task_time_ids = self.env['yuthon.task.time'].search([('name', '=', '30分钟')])
new_record = super(InheritRoomBooking, self).create(vals)
employee_list = []
if new_record.room_users_ids:
for user_id in new_record.room_users_ids:
if user_id.employee_id:
employee_list.append(user_id.employee_id.id)
if task_time_ids:
start_datetime = new_record.start_datetime
start_date = start_datetime.date()
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,
'address' : new_record.room_id.name,
'task_state': 'will',
})
return new_record