Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIG] [17.0] exam : Migrated into 17.0 #282

Open
wants to merge 3 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions exam/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

{
"name": "Exam Management for Education ERP",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"author": "Serpent Consulting Services Pvt. Ltd.",
"website": "http://www.serpentcs.com",
"category": "School Management",
"license": "AGPL-3",
"summary": "A Module For Exams Management Taken In School",
"complexity": "easy",
"images": ["static/description/exam_banner.png"],
"images": ["static/description/Banner_exam_17.png"],
"depends": ["school", "timetable"],
"data": [
"security/exam_security.xml",
Expand Down
55 changes: 27 additions & 28 deletions exam/models/exam.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,40 @@ class StudentStudent(models.Model):
)

def set_alumni(self):
"""Override method to make exam results of student active false
when student is alumni"""
"""Override method to make exam results of student inactive
when student is marked as alumni."""
addexam_result_obj = self.env["additional.exam.result"]
regular_examresult_obj = self.env["exam.result"]

for rec in self:
addexam_result_rec = addexam_result_obj.search(
[("student_id", "=", rec.id)]
addexam_result_obj.search([("student_id", "=", rec.id)]).write(
{"active": False}
)
regular_examresult_rec = regular_examresult_obj.search(
[("student_id", "=", rec.id)]
regular_examresult_obj.search([("student_id", "=", rec.id)]).write(
{"active": False}
)
if addexam_result_rec:
addexam_result_rec.active = False
if regular_examresult_rec:
regular_examresult_rec.active = False
return super(StudentStudent, self).set_alumni()

return super().set_alumni()

@api.model
def _search(
self,
args,
domain,
offset=0,
limit=None,
order=None,
count=False,
access_rights_uid=None,
):
"""Override method to get exam of student selected."""
if self._context.get("exam"):
exam_obj = self.env["exam.exam"]
exam_rec = exam_obj.browse(self._context.get("exam"))
std_ids = [std_id.id for std_id in exam_rec.standard_id]
args.append(("standard_id", "in", std_ids))
return super(StudentStudent, self)._search(
args=args,
domain.append(("standard_id", "in", std_ids))
return super()._search(
domain=domain,
offset=offset,
limit=limit,
order=order,
count=count,
access_rights_uid=access_rights_uid,
)


Expand Down Expand Up @@ -89,7 +83,7 @@ def unlink(self):
raise ValidationError(
_("You cannot delete schedule of exam which is in running!")
)
return super(ExtendedTimeTable, self).unlink()
return super().unlink()

@api.constrains("exam_timetable_line_ids")
def _check_exam(self):
Expand Down Expand Up @@ -219,7 +213,8 @@ def check_exam_date(self):
raise ValidationError(
_(
f"{self.class_room_id.name} is occupied by \
{record.name} for {record.standard_id.standard_id.name} class!"
{record.name} for \
{record.standard_id.standard_id.name} class!"
)
)

Expand All @@ -234,6 +229,10 @@ class ExamExam(models.Model):
def check_date_exam(self):
"""Method to check constraint of exam start date and end date."""
for rec in self:
if rec.start_date < fields.date.today():
raise ValidationError(
_("Exam date should be greater than today's date!")
)
if rec.end_date < rec.start_date:
raise ValidationError(
_("Exam end date should be greater than start date!")
Expand Down Expand Up @@ -299,7 +298,7 @@ def create(self, vals):
vals["exam_code"] = self.env["ir.sequence"].next_by_code("exam.exam") or _(
"New"
)
return super(ExamExam, self).create(vals)
return super().create(vals)

def set_to_draft(self):
"""Method to set state to draft"""
Expand Down Expand Up @@ -445,7 +444,7 @@ def create(self, vals):
vals["addtional_exam_code"] = self.env["ir.sequence"].next_by_code(
"additional.exam"
) or _("New")
return super(AdditionalExam, self).create(vals)
return super().create(vals)

@api.constrains("maximum_marks", "minimum_marks")
def check_marks(self):
Expand Down Expand Up @@ -574,13 +573,13 @@ def create(self, vals):
"""Inherited the create method to assign the roll no and std"""
if vals.get("student_id"):
vals.update(self._update_rollno_standard(vals.get("student_id")))
return super(ExamResult, self).create(vals)
return super().create(vals)

def write(self, vals):
"""Inherited the write method to update the roll no and std"""
if vals.get("student_id"):
vals.update(self._update_rollno_standard(vals.get("student_id")))
return super(ExamResult, self).write(vals)
return super().write(vals)

def unlink(self):
"""Inherited the unlink method to check the state at the deletion."""
Expand All @@ -589,7 +588,7 @@ def unlink(self):
raise ValidationError(
_("You can delete record in unconfirm state only!")
)
return super(ExamResult, self).unlink()
return super().unlink()

@api.onchange("student_id")
def onchange_student(self):
Expand Down Expand Up @@ -790,13 +789,13 @@ def create(self, vals):
"""Override create method to get roll no and standard"""
if vals.get("student_id"):
self._update_student_vals(vals)
return super(AdditionalExamResult, self).create(vals)
return super().create(vals)

def write(self, vals):
"""Override write method to get roll no and standard"""
if vals.get("student_id"):
self._update_student_vals(vals)
return super(AdditionalExamResult, self).write(vals)
return super().write(vals)

@api.onchange("student_id")
def onchange_student(self):
Expand Down
4 changes: 2 additions & 2 deletions exam/report/result_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def _get_report_values(self, docids, data=None):
if not student_search or rec.state == "draft":
raise ValidationError(
_(
"""You cannot print report for student
in unconfirm state or when data is not found !"""
"You cannot print report for student"
"in unconfirm state or when data is not found !"
)
)
return {
Expand Down
Binary file added exam/static/description/Banner_exam_17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified exam/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added exam/static/description/icon_old.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion exam/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<section class="oe_container oe_dark">
<div class='oe_row oe_cover'>
<a href="http://www.serpentcs.com" target="new" ><img src="serpent_logo.png" align="right"></a>
</div>
</div>
</section>

<section class="oe_container">
Expand Down
Loading