From 9035116de53b0deaaa1188d61ffda5b693244454 Mon Sep 17 00:00:00 2001 From: RiteshSerpentCS Date: Mon, 6 Jan 2025 14:35:10 +0530 Subject: [PATCH 1/3] [MIG] exam : Migrated into 17.0 --- exam/__manifest__.py | 2 +- exam/models/exam.py | 55 +++++---- exam/report/result_info.py | 4 +- exam/static/description/index.html | 2 +- exam/views/exam_view.xml | 138 ++++++++++++--------- exam/wizard/exam_subject_result_view.xml | 3 +- exam/wizard/move_standards.py | 146 ++++++++++++----------- 7 files changed, 192 insertions(+), 158 deletions(-) diff --git a/exam/__manifest__.py b/exam/__manifest__.py index 32d09163..04904ed3 100644 --- a/exam/__manifest__.py +++ b/exam/__manifest__.py @@ -2,7 +2,7 @@ { "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", diff --git a/exam/models/exam.py b/exam/models/exam.py index 8764d595..2e222c8e 100644 --- a/exam/models/exam.py +++ b/exam/models/exam.py @@ -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, ) @@ -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): @@ -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!" ) ) @@ -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!") @@ -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""" @@ -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): @@ -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.""" @@ -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): @@ -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): diff --git a/exam/report/result_info.py b/exam/report/result_info.py index d678efa5..1a3fb359 100644 --- a/exam/report/result_info.py +++ b/exam/report/result_info.py @@ -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 { diff --git a/exam/static/description/index.html b/exam/static/description/index.html index 00bd62c2..72fd4751 100644 --- a/exam/static/description/index.html +++ b/exam/static/description/index.html @@ -1,7 +1,7 @@
-
+
diff --git a/exam/views/exam_view.xml b/exam/views/exam_view.xml index 68fc9e10..0205f32c 100644 --- a/exam/views/exam_view.xml +++ b/exam/views/exam_view.xml @@ -21,7 +21,7 @@ name="%(action_stu_result_form)d" class="oe_inline oe_stat_button" type="action" - attrs="{'invisible':[('state', 'in', ['draft','terminate','alumni','cancel'])]}" + invisible="state in ['draft','terminate','alumni','cancel']" groups="school.group_school_administration,school.group_school_teacher,school.group_school_student" >