当前位置:网站首页>dtcloud的消息机制(一)
dtcloud的消息机制(一)
2022-07-13 19:18:00 【姜振建 15954039008】
一、发送消息
1、发送消息
语法:
message_post(self, body='', subject=None, message_type='notification', subtype=None, parent_id=False, attachments=None, **kwargs)
在已存在的线程中发送一条信息,返回一个新的mail.message ID.
参数说明:
body (str) –消息内容,
message_type (str) – 消息类型
parent_id (int) – 父对象ID
attachments (list(tuple(str,str))) – 附件列表(名称,内容), 当内容不是code64位编码的时候。
**kwargs – 参数列表
subtype=None –子类
如subtype="mail.mt_comment":给mail.mt_comment这个模型的关注者发送消息
Returns: 新创建的mail.message记录的ID
Return type int:返回数据类型int
2、调用视图模板发送消息
语法:
message_post_with_view(views_or_xmlid, **kwargs)
调用VIEW视图模板作为辅助方法发送消息。
参数说明:
ir.ui.view record (str) – 模板ID
3、调用qweb模板发送消息
语法:
message_post_with_template(template_id, **kwargs)
调用QWEB模板作为辅助方法发送消息。
参数说明:
template_id – 模板ID
二、接受消息
当一条e-mail被邮件路由处理的时候,下面的 方法会被调用。
1、创建消息
message_new(msg_dict, custom_values=None)
根据相关的模型创建新的消息
参数说明:
msg_dict (dict) –消息内容和附件集合
custom_values (dict) – 自定义值
Return type int:返回数据类型int
Returns: 新创建的mail.message记录的ID
2、修改消息
message_update(msg_dict, update_vals=None)
参数说明:
msg_dict (dict) – 消息内容和附件集合.
update_vals (dict) – 要修改的值
Returns:True– 返回 true
三、“关注者”管理
1、
message_subscribe(partner_ids=None, channel_ids=None, subtype_ids=None, force=True)
添加伙伴到“关注者”
参数说明:
partner_ids (list(int)) – 伙伴IDS
channel_ids (list(int)) – 频道IDS
subtype_ids (list(int)) – 子类型IDS
force –如果设为 True, 在添加新的关注者前删除原有关注者
Returns:Success/Failure 返回成功/失败
Return type:bool返回类型:逻辑
2、
message_unsubscribe(partner_ids=None, channel_ids=None)
从记录的关注者中移动伙伴
参数说明:
partner_ids (list(int)) – 伙伴IDS
channel_ids (list(int)) – 频道IDS
Returns:True 返回真
Return type:bool返回类型:逻辑
3、
message_unsubscribe_users(user_ids=None)
Wrapper on message_subscribe, using users.
参数说明:
user_ids (list(int)) – 将取消订阅记录的用户的ID;如果没有,请取消订阅当前用户
Returns:True 返回真
Return type:bool返回类型:逻辑
四、日志记录管理
mail模块有字段修改跟踪功能,允许在特定字段上记录所有修改过程,如下:
例子:
class BusinessTrip(models.Model):
_name = 'business.trip'
_inherit = ['mail.thread']
_description = 'Business Trip'
name = fields.Char(tracking=True)
partner_id = fields.Many2one('res.partner', 'Responsible',
tracking=True)
guest_ids = fields.Many2many('res.partner', 'Participants')
中亿丰数字 姜振建
边栏推荐
- PG运维篇--服务启停
- 孤儿进程、僵尸进程和进程退出(针对面试)
- What is restful style? What is the difference from the traditional interview style?
- Interprocess communication (very practical)
- Shutter renderflex overflowed by pixels on the bottom keyboard pop-up warning exception
- 拔掉电源会怎样?GaussDB(for Redis)双活让你有备无患
- Flink SQL 求上一个月 是哪个函数?
- input获取焦点
- Development of management
- Focusing on data center innovation, what new forces does NVIDIA DOCA 1.3 bring
猜你喜欢

Leetcode (Sword finger offer) - 45 Arrange the array into the smallest number

人工智能与 RPA 技术应用(一)-RPA弘玑产品介绍、设计器界面功能讲解

How to apply for PMP project management certification examination?

QT+VS 工程在 Release/Debug 文件夹下导入相关 DLL (非常实用)

Hcip day 6 notes

孤儿进程、僵尸进程和进程退出(针对面试)

【Day 2】机器阅读理解——常见机器阅读理解模型(上)

Hcip first day notes

Virtualization path of GPU resource pool

Hcip day 5 experiment
随机推荐
Hcip second day notes
LeetCode 1584. Minimum cost of connecting all points
How to recover the files deleted by win11 security center?
HCIP第二个实验
Hj8 consolidated statement record hj08
Hardware iic+dma operation sharing based on stm32f405
JMeter 21 day clock in day01
Hcip third day notes
CloudCompare&PCL 点云最小二乘法拟合平面
HCIP静态路由
LeetCode 2155. All subscripts with the highest score in the group
人工智能与 RPA 技术应用(一)-RPA弘玑产品介绍、设计器界面功能讲解
【无标题】
Running process of program
Web security - DOS regular expression denial of service attack
Burpsite v2.1 Chinese version
Response. Write specific introduction
What if the win11 touchpad doesn't work? The solution of win11 touch panel not working
进程间通信(非常实用)
np.unravel_index() 求出数组某元素(或某组元素)拉成一维后的索引值在原本维度(或指定新维度)中对应的索一般与np.argmax(A) 或 np.argmin(A) 配合使用