I am trying to compute a field in my model to be a concatenation of the names of another model which has a many2many relationship with my model:
class p2_vm(models.Model):
_name = 'p2.vm'
def _get_hostfunction_names(self):
names = []
for id in self.hostfunction_ids:
names.append(id.name)
self.functions = ','.join(names)
hostfunction_id = fields.Many2many('p2.hostfunction')
functions = fields.Char(compute=_get_hostfunction_names)
The other model has:
class p2_hostfunction(models.Model):
_name = 'p2.hostfunction'
name = fields.Char('Name', required=True)
vm_id = fields.Many2many('p2.vm')
How can I accomplish what I want?