任何人都可以告诉如何在聊天中增加关注者 ..我已经在表单中创建了oe_chatter并且它也显示了但是任何人都可以告诉我是否在one2many字段中添加了许多员工然后粉丝也同时增加 这是我尝试的代码。
PY
_inherit = ['mail.thread','ir.needaction_mixin','utm.mixin']
XML
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
<field name="message_ids" widget="mail_thread"/>
</div>
答案 0 :(得分:0)
from odoo import fields,api,models
class your_class(models.Model):
_name = "hr_work_shifts.hr_shifts"
_inherit = ['mail.thread','ir.needaction_mixin','utm.mixin']
@api.model
def create(self,vals):
res = super(hrWorkShifts,self).create(vals)
for emp in res.emp_name_ids:
res.message_follower_ids = [(4,emp.emp_id.id)]
return res
emp_name_ids = fields.One2many('employee.list','emp_id',string='Employee Name')
class employee_list(models.Model):
_name="employee.list"
emp_id = fields.Many2one('res.partner',string="Employee Name")
date = fields.Date('Date')
将emp_name_ids
字段放入视图中以添加员工姓名和日期。