如何在 Odoo 中使用 Chatter?

How to use Chatter in Odoo?

我想将 Chatter 用于学生模型,这样,当某些字段的值更改时,它会记录在学生表格下

为了实现这一点,我做了以下事情: 1.添加了这个div

<div class="oe_chatter">
    <field name="message_follower_ids" widget="mail_followers"/>
    <field name="message_ids" widget="mail_thread"/>
</div>

在学生表格中。

它添加了聊天,但是当我点击 New Message 按钮时,它给出了以下错误。

这可能是因为我没有继承mail.thread学生模式。

  1. 然后我在学生模型中继承了这个class。

然后又报错如下图

我搜索了这个主题,但找不到任何内容。

如果有人能帮助我,我将不胜感激。

为了记录您需要的特定字段的更改,请在您要跟踪的每个字段上设置 track_visibility 属性:

class OpStudent(models.Model):
    _name = 'op.student'
    _inherits = {
        'res.partner': 'partner_id',
    }
    _inherit = [
        'mail.thread',
        'ir.needaction_mixin',
    ]

    foo = fields.Char(track_visibility='always')

您可以在 official documentation 中阅读更多相关信息。

您正在使用 Chatter 来跟踪学生的详细信息。

所以我会推荐另一个模块,它工作得非常好,可以跟踪学生或任何其他你想要的模型,因为我亲自使用过它。

我用了audit log。它跟踪所有的 CRUD 操作。它将创建 Audit 从那里的设置选项卡中的菜单,您可以设置要跟踪的模型。

作为参考,您也可以查看这张图片。

我遇到了同样的问题,但是res.company,我是这样解决的:

class ResCompany(models.Model):

    _name = 'res.company'
    _inherit = ['res.company','mail.thread', 'mail.activity.mixin']

    date_end = fields.Date(string="Fin Date",tracking=True)

在xml中:

<xpath expr="//form/sheet" position="after">

    <div class="oe_chatter">
    <field name="message_follower_ids" widget="mail_followers"/>
    <field name="message_ids" widget="mail_thread" />
    </div>
</xpath>

希望对您有用。