odoo_18_Education_management/models/school_student.py

46 lines
2.0 KiB
Python

from odoo import models, fields, api
class SchoolStudent(models.Model):
_name = 'school.student'
_description = 'Student'
application_id = fields.Many2one('school.application', string="Application", required=True)
student_id = fields.Char(string="Student ID", compute='_compute_student_id', store=True)
# Related fields (autofilled from application)
student_name = fields.Char(related='application_id.name', string="Student Name", store=True)
profile_photo = fields.Binary(related='application_id.image', string="Profile Photo", store=True)
phone_no = fields.Char(related='application_id.phone_no', string="Phone No", store=True)
roll_no = fields.Char(related='application_id.roll_no', string="Roll Number", store=True, readonly=True)
school_id = fields.Many2one('res.company', string="School", default=lambda self: self.env.company)
enrollment_date = fields.Date(string="Enrollment Date")
class_name = fields.Selection([
('1', 'Class 1'), ('2', 'Class 2'), ('3', 'Class 3'), ('4', 'Class 4'),
('5', 'Class 5'), ('6', 'Class 6'), ('7', 'Class 7'), ('8', 'Class 8'),
('9', 'Class 9'), ('10', 'Class 10'), ('11', 'Class 11'), ('12', 'Class 12'),
], string="Class", required=True)
academic_year = fields.Char(string="Academic Year")
session_status = fields.Selection([
('active', 'Active'),
('completed', 'Completed'),
('suspended', 'Suspended')
], string="Session Status")
payment_term = fields.Char(string="Payment Term")
def action_generate_payment_slip(self):
return {
'type': 'ir.actions.act_window',
'name': 'Fee Slip',
'res_model': 'school.enrollment.fee.summary',
'view_mode': 'tree,form',
'domain': [('student_ref', '=', self.id)],
'target': 'current',
}
@api.depends('application_id')
def _compute_student_id(self):
for rec in self:
rec.student_id = str(rec.application_id.id) if rec.application_id else ''