Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odgovori
5140 Prikazi

Hi

I would add a many2many field to my form to get able to add some more users as follower to my module

This is my python code now

def default_recipient(self):
rec_type = self.env.context.get('rec', False)
if rec_type == 'recipient':
return self.env.user.company_id.partner_id

recipient_partner_id = fields.Many2many(
'res.partner',
string='Recipient',
track_visibility='onchange',
default=default_recipient)

and this is .xml file

<group>
<field name="recipient_partner_id" readonly="1"/>
<field name="name" attrs="{'readonly': [('state', 'not in', ['draft'])]}"/>
</group>

so how can i add this partner as follower

do any one know how to do?

Thanks guys

Avatar
Opusti
Best Answer

Hello,

You can try this.

@api.model

def create(self, vals):

res = super(<Your class Name>, self).create(vals)

if res.recipient_partner_id:

for partner in res.recipient_partner_id:

    vals['message_follower_ids'] += self.env['mail.followers']._add_follower_command(self._name, [], {partner.id}, {})[0]

return res

Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
1
maj 19
4398
2
avg. 24
1109
0
apr. 21
2268
0
feb. 21
214
2
okt. 23
8541