odoo_18_Education_management/models/enrollment.py

58 lines
2.3 KiB
Python

from odoo import models, fields, api
_inherit = ['mail.thread', 'mail.activity.mixin']
class SchoolEnrollment(models.Model):
_name = 'school.enrollment'
_description = 'Enrollment'
application_id = fields.Many2one('school.application', string="Student", required=True)
school_id = fields.Many2one('res.company', string="School", default=lambda self: self.env.company)
student_id = fields.Char(string="Student ID", compute='_compute_student_id', store=True)
student_name = fields.Many2one('school.application', string="Student", ondelete='set null')
image = fields.Binary("Profile Photo", store=True)
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)
course = fields.Char(string="Course")
session = fields.Char(string="Session")
academic_year = fields.Char(string="Academic Year")
fees_structure = fields.Char(string="Fees Structure")
fees_status = fields.Selection([
('paid', 'Paid'),
('partial', 'Partially Paid'),
('unpaid', 'Unpaid')
], string="Fees Status", default="unpaid")
session_status = fields.Selection([
('active', 'Active'),
('completed', 'Completed'),
('drop', 'Dropped')
], string="Session Status", default="active")
enrollment_date = fields.Date(string="Enrollment Date")
status = fields.Selection([
('draft', 'Draft'),
('confirmed', 'Confirmed'),
('cancelled', 'Cancelled')
], string="Status", default='draft')
subject_line_ids = fields.One2many('school.enrollment.subject', 'enrollment_id', string="Subjects")
fee_summary_line_ids = fields.One2many('school.enrollment.fee.summary', 'enrollment_id', string="Fee Summary")
course_id = fields.Many2one('school.course', string='Course', ondelete='cascade', required=True)
student_id = fields.Many2one('res.partner', string='Student', required=True)
@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 ''