美文网首页odoopython
odoo 消息(发送消息,记录备注)

odoo 消息(发送消息,记录备注)

作者: 隔壁小红馆 | 来源:发表于2020-05-27 16:56 被阅读0次

    有时需要在表单的下面有操作记录以及某些字段的变化信息展示

    image.png

    首先就是要继承消息模型

    - 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>
    

    针对某个操作的记录


    image.png
    image.png
    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')
    两种貌似一样的效果
    可自行测试,有不同结果的告诉我一下哈。

    制作不易,点赞鼓励哈

    相关文章

      网友评论

        本文标题:odoo 消息(发送消息,记录备注)

        本文链接:https://www.haomeiwen.com/subject/eitgahtx.html