跳至内容
菜单
此问题已终结
2 回复
3029 查看

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 !

形象
丢弃
最佳答案

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)]})
形象
丢弃
编写者

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 !

最佳答案

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


形象
丢弃
相关帖文 回复 查看 活动
1
6月 25
15362
3
4月 25
5533
2
7月 24
2532
1
2月 24
2020
1
1月 24
1811