from odoo import models, fields class EducationStudent(models.Model): _name = 'education.student' name = fields.Char(string="Name") student_code = fields.Char(string='Student Code') class_id = fields.Many2one('education.class', string='Class') def get_student_has_class(self): return self.env['education.student'].search([('class_id', '!=', False)])