Python 点击统计按钮后如何过滤与同一型号相关的特定记录 注册学校模式 用于registration.school模型的xml文件

Python 点击统计按钮后如何过滤与同一型号相关的特定记录 注册学校模式 用于registration.school模型的xml文件,python,odoo,Python,Odoo,它显示registration.student表中的学生人数。 但在点击统计按钮后,它应该只显示与该学校相关的学生数据。因为学校和学生之间有着千丝万缕的联系。但它显示了学生模型中出现的所有学生记录。如何解决这个问题。有人吗?在您的操作中将域添加到筛选记录中 @api.multi def行动\u计数\u学生(自我): self.sure_one() 返回{ “名称”:“操作”, 'type':'ir.actions.act_window', “查看模式”:“树,窗体”和“删除搜索”,因为它会自动显

它显示registration.student表中的学生人数。
但在点击统计按钮后,它应该只显示与该学校相关的学生数据。因为学校和学生之间有着千丝万缕的联系。但它显示了学生模型中出现的所有学生记录。如何解决这个问题。有人吗?

在您的操作中将域添加到筛选记录中

@api.multi
def行动\u计数\u学生(自我):
self.sure_one()
返回{
“名称”:“操作”,
'type':'ir.actions.act_window',
“查看模式”:“树,窗体”和“删除搜索”,因为它会自动显示在可搜索视图(如树视图)中
“resu模型”:“registration.student”,
#我不知道学生注册中m2o的名字,假设它是学校id
'domain':[('school_id','=',self.id)],
“res_id”:self.id,
}
def action_count_student(self):
    return {
        'name': 'action',
        'type': 'ir.actions.act_window',
        'view_mode': 'tree,form,search',
        'res_model': 'registration.student',
        'res_id': self.id,
        }
<div class="oe_button_box" name="button_box">
                    <button class="oe_stat_button" type="object"  name="action_count_student" icon="fa-graduation-cap" >
                        <field name="count" string="Student" widget="statinfo"/>
                    </button>
                    <button class="oe_stat_button" type="object"  name="action_count_teacher" icon="fa-teacher" >
                        <field name="count_teacher" string="Teacher" widget="statinfo"/>
                    </button>
                </div>