在odoo中发送特定组的通知

Soa*_*aad 2 python odoo

我想为manfacture组中的每个人发送通知,所以我尝试了这个代码,但它不起作用

manf_categ_ids=self.pool.get('ir.module.category').search(cr,uid,[('name','=','Manufacturing')],context=context)[0]
    users=self.pool.get('res.groups').browse(cr, uid, manf_categ_ids , context=context).users
    for user in users:
        recipient_partners = []
        recipient_partners.append(
            (4, user.partner_id.id)
        )       
    #user_ids=self.pool.get('res.users').search(cr,uid,[('groups_id','=',manf_categ_ids)],context=context)
    post_vars = {'subject': "notification about order",
         'body': "Yes inform me as i belong to manfacture group",
         'partner_ids': recipient_partners,} # Where "4" adds the ID to the list 
                                   # of followers and "3" is the partner ID 
    thread_pool = self.pool.get('mail.thread')
    thread_pool.message_post(
            cr, uid, False,
            type="notification",
            subtype="mt_comment",
            context=context,
            **post_vars)
Run Code Online (Sandbox Code Playgroud)

2个用户属于制造组的问题,但用户列表只包含1个元素,当我使用该用户登录时,此代码不发送任何通知

小智 5

问题似乎是你每次迭代清除列表.

这条线

recipient_partners = []
Run Code Online (Sandbox Code Playgroud)

应该不在for循环中.