[已解决] 获取Followers的User id
-
@hui
获取mail.follower
对象self.message_follower_ids
或者下面的也是获取的mail.follower
对象followers = self.env['mail.followers'].sudo().search([ ('res_model', '=', self._name), ('res_id', '=', self.id)])
但是
followers
并不一定是users
。疑问:不知道
mail.follower
中的partner_id
是什么作用,这个res_id
应该是当前单据的id吧。获取
Followers中的User
好像没有一步到位的方法,官方也没有提供对应的方法或者属性可用。只能自己写了:follower_partner_ids = self.message_follower_ids.mapped('partner_id').ids for partner_id in follower_partner_ids: if partner_id: follower_users_ids = self.env['res.users'].search([('partner_id', '=', partner_id)]).ids
-
# Note. There is no integrity check on model names for performance reasons. # However, followers of unlinked models are deleted by models themselves # (see 'ir.model' inheritance). res_model = fields.Char( 'Related Document Model Name', required=True, index=True) res_id = fields.Integer( 'Related Document ID', index=True, help='Id of the followed resource') partner_id = fields.Many2one( 'res.partner', string='Related Partner', ondelete='cascade', index=True) channel_id = fields.Many2one( 'mail.channel', string='Listener', ondelete='cascade', index=True) subtype_ids = fields.Many2many( 'mail.message.subtype', string='Subtype', help="Message subtypes followed, meaning subtypes that will be pushed onto the user's Wall.")
mail.follower
关联res.partner
,因为关注者不一定是系统的登录用户,他们只需要通过邮件收到对应的信息就可以了。
res_id
就是关联的单据id。
res_model
是关联的单据模型。