【发布时间】:2018-06-01 23:29:36
【问题描述】:
我有一个名为“student”的模型,它与一个名为“authorized”的模型具有多对多关系,另一个名为“authorized”的模型与“学生”模型具有多对多关系。另一方面,我有第三个模型,名为“exit_control”,它包含与模型“student”的多对一关系。
我想要模型“exit_control”中的第二个字段 many2one,它只显示与所选学生相关的授权。
也就是说:如果student1与authorized6和authorized8相关,并且authorized的完整表有20个authorized,我在模型exit_control的student_id字段中选择student1,我想显示一个字段many2one和authorized6和授权8.
学生模型有:
authorized_ids = fields.Many2many('aula10.authorized', string='Authorizeds')
授权模型有:
authorized_for_ids = fields.Many2many('aula10.student', string='Can get this student:')
Exit_control 模型有:
student_id = fields.Many2one('aula10.student',string='Student') Given_to_id = fields.Many2one('aula10.authorized', string='Given to:')
Given_to_id 是我想用来显示过滤后的授权的字段。
我尝试在视图和模型中使用属性域,但对我来说是不可能的。
你能帮帮我吗?
【问题讨论】:
-
解决了!解决方案是 Given_to_id = fields.Many2one('aula10.authorized', string='Given to:' , domain="[('authorized_for_ids', '=', student_id)]")