0
votes

I have a model named "student" that had a many2many relation with a model named "authorized" and another model named "authorized" with a many2many relation with the model "student". In the other hand, I have a third model named "exit_control" that contains a many2one relation with the model "student".

I wanna a second field many2one in the model "exit_control" that shows only the authorizeds related with the student selected.

In other words: if student1 is related with authorized6 and authorized8, and the complete table of authorized had 20 authorizeds, and I select the student1 in the field student_id of the model exit_control, I wanna show a field many2one with the authorized6 and authorized8.

Student model had:

authorized_ids = fields.Many2many('aula10.authorized', string='Authorizeds')

Authorized model had:

authorized_for_ids = fields.Many2many('aula10.student', string='Can get this student:')

Exit_control model had:

student_id = fields.Many2one('aula10.student',string='Student')
Given_to_id = fields.Many2one('aula10.authorized', string='Given to:')

Given_to_id is the field that I wanna use for show the filtered authorizeds.

I tried to use the attribute domain in view and in model, but was impossible for me.

Can you help me, please?

1
Solved! Solution was Given_to_id = fields.Many2one('aula10.authorized', string='Given to:' , domain="[('authorized_for_ids', '=', student_id)]")Daniel Ruiz

1 Answers

0
votes

In model definition?

Given_to_id = fields.Many2one('aula10.authorized', string='Given to:', domain=[('authorized_for_ids', 'in', [student_id ])])

eventaully you can use computed field with store option?