api依赖于widget ='mail_thread'不起作用

时间:2018-01-24 20:54:46

标签: python python-2.7 odoo-10

我有这个问题,我有一个字段,当您点击社交网络上的发送消息时过滤消息,但我的问题是我必须刷新页面才能获取数据。我想在发送信息的同时得到它。

 @api.multi
 @api.depends('message_ids')
 def _compute_defect_summary_attachment_ids(self):
    body = ' '
    attachments = []
    cont = 1
    for rec in self:
        for msj in rec.message_ids:
            if msj.message_type == 'comment' and msj.subtype_id.name == 'Debates':
                soup = BeautifulSoup(msj.body)
                body += u'- Observación ' + str(cont) + ': ' + soup.text + '\n' \
                        + '- Reportante: ' + msj.create_uid.name + '\n' \
                        + '- Fecha: ' + msj.date + '\n\n'
                cont += 1
        rec.update({
            'defect_summary': body})

尝试修复它,我看到添加小部件时不起作用。任何的想法?我还需要使用小部件。

1 个答案:

答案 0 :(得分:1)

odoo 10:在你的类中继承mail.thread对象,你也可以在view中添加message_ids。你可以在任何模块或类中使用。

1)models / custom.py

 class CustomDetails(models.Model):
     _name = 'custom.details'
     _inherit = ['mail.thread', 'ir.needaction_mixin']

2)views / custom_view.xml

<field name="message_ids" widget="mail_thread"/>