新增消息通知模块
This commit is contained in:
58
jikimo_message_notify/models/jikimo_message_template.py
Normal file
58
jikimo_message_notify/models/jikimo_message_template.py
Normal file
@@ -0,0 +1,58 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class JikimoMessageTemplate(models.Model):
|
||||
_name = "jikimo.message.template"
|
||||
_description = '消息模板'
|
||||
|
||||
name = fields.Char(string="名称", required=True)
|
||||
|
||||
description = fields.Char(string="描述")
|
||||
content = fields.Html(string="内容", render_engine='qweb', translate=True, prefetch=True, sanitize=False)
|
||||
msgtype = fields.Selection(
|
||||
[('text', '文字'), ('markdown', 'Markdown')], '消息类型',
|
||||
required=True, default='markdown')
|
||||
notification_department_id = fields.Many2one('hr.department', '通知部门', required=True)
|
||||
notification_employee_ids = fields.Many2many('hr.employee', string='员工',
|
||||
domain="[('department_id', '=',notification_department_id)]",
|
||||
required=True)
|
||||
|
||||
urgency = fields.Selection([
|
||||
("normal", "普通"),
|
||||
("urgent", "紧急"),
|
||||
("very_urgent", "非常紧急")
|
||||
], string="紧急程度")
|
||||
active = fields.Boolean(string="是否有效", default=True)
|
||||
|
||||
def _get_message_model(self):
|
||||
"""
|
||||
获取通知的模型
|
||||
"""
|
||||
return []
|
||||
|
||||
def _get_model(self):
|
||||
return self.model
|
||||
|
||||
model_id = fields.Many2one(
|
||||
"ir.model",
|
||||
string="关联模型",
|
||||
domain=lambda self: [("model", "in", self._get_message_model())]
|
||||
)
|
||||
model = fields.Char(related="model_id.model", index=True, store=True)
|
||||
bussiness_node_id = fields.Many2one(
|
||||
"jikimo.message.bussiness.node",
|
||||
string="业务节点",
|
||||
domain=lambda self: [("model", "=", self.model)],
|
||||
required=True
|
||||
)
|
||||
|
||||
@api.onchange('notification_department_id')
|
||||
def _clear_employee_ids(self):
|
||||
if self.notification_department_id:
|
||||
self.notification_employee_ids = False
|
||||
|
||||
def test_send_message(self):
|
||||
self.env["jikimo.message.dispatch"]._cron_dispatch()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user