Files
gzth/room/models/inherit_calendar_event.py
T
2025-12-02 21:44:08 +08:00

34 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models, tools, _
from odoo.exceptions import UserError, ValidationError
class CalendarEvent(models.Model):
_inherit = "calendar.event"
sth_type = fields.Selection([('sth', '日程'), ('meet', '会议')], default="sth", string="活动类型")
room_booking_id = fields.Many2one('room.booking', string="会议")
name = fields.Char(string="日程名称", default='新建')
def button_meet(self):
# 开始时间结束时间开始日期结束日期,后期优化
# 传值后续优化,考虑name = False
if self.sth_type == 'meet':
raise UserError('该日程已经安排会议')
return {
"name": _("会议"),
"type": "ir.actions.act_window",
"view_mode": "form",
"res_model": "room.booking",
"views": [[self.env.ref('room.room_booking_view_form').id, "form"]]
}
def button_dates(self):
return {
"name": _("日程"),
"type": "ir.actions.act_window",
"view_mode": "form",
"res_model": "calendar.event",
"views": [[self.env.ref('calendar.view_calendar_event_form').id, "form"]]
}