如何在odoo10中增加oe_chatter中的关注者

时间:2017-07-26 19:04:01

标签: python-3.x odoo-10

任何人都可以告诉如何在聊天中增加关注者 ..我已经在表单中创建了oe_chatter并且它也显示了但是任何人都可以告诉我是否在one2many字段中添加了许多员工然后粉丝也同时增加 here follower is one but in one2many field many employees added then followers also increases 这是我尝试的代码。

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>  

1 个答案:

答案 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字段放入视图中以添加员工姓名和日期。