回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我想给制造组的每个人发一份通知,所以我试过这个代码,但它不起作用</p>
<pre><code>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.<a href="https://www.cnpython.com/list/append" class="inner-link">append</a>(
(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)
</code></pre>
<p>2个用户属于制造组,但用户列表仅包含1个元素,当我使用此用户登录时,此代码不发送任何通知</p>