46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
|
from odoo import models, fields,api
|
||
|
from odoo.exceptions import UserError
|
||
|
|
||
|
class SchoolCourseAssignment(models.Model):
|
||
|
_name = 'school.course.assignment'
|
||
|
_description = 'Course Assignment'
|
||
|
|
||
|
course_id = fields.Many2one('school.course', string='Course', ondelete='cascade')
|
||
|
type = fields.Char(string='Assignment Type')
|
||
|
weightage = fields.Float(string='Weightage')
|
||
|
teacher = fields.Many2one('res.users', string='Teacher')
|
||
|
class_id = fields.Many2one('school.class', string='Class')
|
||
|
subject_id = fields.Many2one('school.subject', string='Subject', ondelete='cascade', required=True)
|
||
|
assignment_count = fields.Integer(
|
||
|
string="No. of Assignments",
|
||
|
compute="_compute_assignment_count",
|
||
|
store=False,
|
||
|
)
|
||
|
|
||
|
is_completed = fields.Selection([
|
||
|
('yes', 'Completed'),
|
||
|
('no', 'Not Completed')
|
||
|
], string='Status', default='no')
|
||
|
|
||
|
due_date = fields.Date(string='Due Date')
|
||
|
|
||
|
@api.depends('course_id')
|
||
|
def _compute_assignment_count(self):
|
||
|
for rec in self:
|
||
|
if rec.course_id:
|
||
|
rec.assignment_count = self.search_count([('course_id', '=', rec.course_id.id)])
|
||
|
else:
|
||
|
rec.assignment_count = 0
|
||
|
|
||
|
|
||
|
def action_send_message(self):
|
||
|
for record in self:
|
||
|
raise UserError("Send Message clicked for %s" % record.name)
|
||
|
|
||
|
def action_log_note(self):
|
||
|
for record in self:
|
||
|
raise UserError("Log Note clicked for %s" % record.name)
|
||
|
|
||
|
def action_schedule_activity(self):
|
||
|
for record in self:
|
||
|
raise UserError("Activity clicked for %s" % record.name)
|