odoo 消息(发送消息,记录备注)
2020-05-27 本文已影响0人
隔壁小红馆
有时需要在表单的下面有操作记录以及某些字段的变化信息展示

首先就是要继承消息模型
- py文件里
_inherit = ['mail.thread', 'mail.activity.mixin']
- xml 里面
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="message_ids" widget="mail_thread"/>
</div>
针对某个操作的记录


body = u"驳回原因: %s" % (self.reasons_rejection)
self.message_post(body=body, message_type='notification')
message_post的 message_type 有两种参数
- notification
- comment
track_visibility='always' 实时监控,修改其他字段也会显示消息
track_visibility='onchange' 当前字段有变化时进行记录消息,一般用此来记录
reasons_rejection = fields.Text('驳回原因', track_visibility='always')
两种貌似一样的效果
可自行测试,有不同结果的告诉我一下哈。
制作不易,点赞鼓励哈