# -*- coding: utf-8 -*- from odoo import models, fields, api from abc import ABC, abstractmethod class SfMessageTemplate(models.Model): _name = "sf.message.template" _description = u'消息模板' name = fields.Char(string=u"名称", required=True) description = fields.Char(string=u"描述") content = fields.Html(string=u"内容", render_engine='qweb', translate=True, prefetch=True, sanitize=False) msgtype = fields.Selection( [('text', u'文字'), ('markdown', u'Markdown')], u'消息类型', required=True, default='markdown') notification_department_id = fields.Many2one('hr.department', u'通知部门', required=True) notification_employee_ids = fields.Many2many('hr.employee', string=u'员工', domain="[('department_id', '=',notification_department_id)]", required=True) is_send_time = fields.Boolean(string=u"定时发送", default=False) send_time_1 = fields.Integer('发送时间点1') send_time_2 = fields.Integer('发送时间点2') active = fields.Boolean(string=u"是否有效", default=True) @api.onchange('notification_department_id') def _clear_employee_ids(self): if self.notification_department_id: self.notification_employee_ids = False @abstractmethod def dispatch(self, args): """ 强迫继承该类必走该抽象方法' """