Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
5176 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
maj 19
4450
2
sie 24
1152
0
kwi 21
2315
0
lut 21
214
2
paź 23
8595