28 lines
1.0 KiB
Python
28 lines
1.0 KiB
Python
from odoo import models, fields, api
|
|
from odoo.exceptions import UserError
|
|
|
|
class SchoolSubjectLesson(models.Model):
|
|
_name = 'school.subject.lesson'
|
|
_description = 'Subject Lesson Plan'
|
|
|
|
subject_id = fields.Many2one('school.subject', string='Subject', ondelete='cascade', required=True)
|
|
title = fields.Char(string='Title', required=True)
|
|
prepared_by = fields.Many2one('res.users', string='Prepared By')
|
|
period = fields.Char(string='Timing Period') # e.g. 10:00 AM - 11:00 AM
|
|
total_lessons = fields.Integer(string='Total Lessons', default=1)
|
|
|
|
teacher = fields.Many2one('res.users', string='Teacher')
|
|
class_id = fields.Many2one('school.class', string='Class')
|
|
|
|
activity_count = fields.Integer(
|
|
string="No. of Activities",
|
|
compute="_compute_activity_count",
|
|
store=False
|
|
)
|
|
|
|
@api.depends('subject_id')
|
|
def _compute_activity_count(self):
|
|
for record in self:
|
|
record.activity_count = len(record.subject_id.teacher_info_line_ids)
|
|
|
|
|