Skip to Content
Menu
This question has been flagged
2 Replies
2125 Views

liste_etudiant = []
for record in self:
if record.x_studio_anne_academique_:
etudiant = self.env['x_apprenant_par_annee'].search([('x_studio_many2one_field_S5CZy.id','=',record.x_studio_anne_academique_.id)])
if etudiant:
for line in etudiant:

liste_etudiant.append(line)

---------------------------------------------------------------------------------------------------

Now my data is in liste_etudiant.

The issue, is how put this data in many2manyfield ?

when i do this :

for f in liste_etudiant:
record.write({' x_studio_many2many_field_knpV7' : f})

I only get one data display in many2many field.

Thanks !

Avatar
Discard
Best Answer

Try the below code:

for record in self:
liste_etudiant = []
if record.x_studio_anne_academique_:
etudiant = self.env['x_apprenant_par_annee'].search(
[('x_studio_many2one_field_S5CZy.id', '=', record.x_studio_anne_academique_.id)])
if etudiant:
for line in etudiant:
liste_etudiant.append(line.id)
if liste_etudiant:
record.write({'x_studio_many2many_field_knpV7': [(6, 0, liste_etudiant)]})
Avatar
Discard
Author

Thanks very much! it's worked.

please, in addition can u explain me action = {} used in automate actions. And how to use it , give me some example of code.

Am very grateful !

Best Answer

hii, I need do similar function, Waleed Ali Mohsen. Please, help me. 

At 6 hours I'll be in office and I'll contact to u


Avatar
Discard
Related Posts Replies Views Activity
2
Jul 24
413
1
Feb 24
839
1
Jan 24
422
2
Apr 24
1951
0
Jul 24
1503