Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
10874 มุมมอง

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')
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

If you want to set the domain of manager based on the Many2many field student_ids try by replacing the domain as following.

manager_id = fields.Many2one('estudiantes.student', string='Responsable', domain="[('id', 'in', student_ids)]")
Try to declare the field manager_id after student_ids

Regards

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
naked domain set up แก้ไขแล้ว
3
ก.ค. 25
4158
0
พ.ค. 25
840
0
ธ.ค. 24
1354
2
มี.ค. 24
2071
Import Data From Another Model แก้ไขแล้ว
1
มี.ค. 24
2416