I need to copy many2many field content to another class' many2many field.
@api.multi
def tester(self):
context = self._context.copy()
list = []
confs = self.risque.rubrique_ids
for rec in confs:
list.append(rec.id)
self.env['test.test'].create({
'nom_risque': self.risque.nom_risque,
'rubrique_ids': [0, 0, list]
})
return {
'name': 'Evaluation',
'view_type': 'form',
'view_mode': 'tree,form',
# 'views': [{'view_mode': 'form', 'view_id': 'rub_id'}],
'res_model': 'test.test',
'type': 'ir.actions.act_window',
'res_id': self.id,
# 'target': 'new',
'flags': {'initial_mode': 'edit'},
'context': context,
}
My XML code:
<button name="tester" string="Evaluer" type="object" class="oe_highlight" />
But it returns the nom_risque and for the rubrique_ids only the last one.