Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
2 Besvarelser
3040 Visninger

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
Kassér
Bedste svar

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
Kassér
Forfatter

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 !

Bedste svar

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
Kassér
Related Posts Besvarelser Visninger Aktivitet
1
jun. 25
15370
3
apr. 25
5547
2
jul. 24
2559
1
feb. 24
2026
1
jan. 24
1816