24 lines
839 B
Python
24 lines
839 B
Python
from odoo import models, fields, api
|
|
|
|
class EducationStudent(models.Model):
|
|
_inherit = 'education.student'
|
|
|
|
exam_result_ids = fields.One2many('education.exam.result', 'student_id', string='Exam Results')
|
|
exam_result_count = fields.Integer(compute='_compute_exam_result_count')
|
|
|
|
@api.depends('exam_result_ids')
|
|
def _compute_exam_result_count(self):
|
|
for student in self:
|
|
student.exam_result_count = len(student.exam_result_ids)
|
|
|
|
def action_view_exam_results(self):
|
|
self.ensure_one()
|
|
return {
|
|
'name': 'Exam Results',
|
|
'type': 'ir.actions.act_window',
|
|
'res_model': 'education.exam.result',
|
|
'view_mode': 'tree,form',
|
|
'domain': [('student_id', '=', self.id)],
|
|
'context': {'default_student_id': self.id},
|
|
}
|