Help

0

How to add a domain to a Many2one field in Odoo?

Avatar
Ernesto Ruiz

I have a custom module to manage students and groups, each group has a list of members (student_ids) and a president (manager_id). The manager should be selected among the list of members. So was traying to add a domain to manager_id field domain="[('id','in',self.student_ids.ids)], so the user can only select a manager from the existing list of students. But that code is giving me an error. What should I do to add that domain to the manager_id field?


class Groups(models.Model):
    _name = 'estudiantes.group'
    _description = 'Permite manejar los grupos a los que pertenecen los estudiantes'

    manager_id = fields.Many2one('estudiantes.student',string='Responsable', domain="[('id','in',self.student_ids.ids)]")
    student_ids = fields.Many2many('estudiantes.student', string='Estudiantes')
Avatar
Discard