diff --git a/README.md b/README.md index 214446cf..bc883592 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -[![Build Status](https://travis-ci.org/JayVora-SerpentCS/OdooEduERP.svg?branch=14.0)](https://travis-ci.org/JayVora-SerpentCS/OdooEduERP) +[![Build Status](https://travis-ci.org/JayVora-SerpentCS/OdooEduERP.svg?branch=16.0)](https://travis-ci.org/JayVora-SerpentCS/OdooEduERP) -# EduERPv14 -Education ERP v14 +# EduERPv16 +Education ERP v16 Serpent Consulting Services Pvt Ltd, the Official Odoo GOLD partner has here contributed the Education ERP. Help us do better by donating to us and motivating us : http://www.serpentcs.com/page/donate-to-serpentcs diff --git a/exam/models/exam.py b/exam/models/exam.py index e16e52a6..5f2ec2a8 100644 --- a/exam/models/exam.py +++ b/exam/models/exam.py @@ -195,6 +195,7 @@ def check_teacher_room(self): and rec.table_id.timetable_type == "exam" and rec.class_room_id == record.class_room_id and rec.start_time == record.start_time + and rec.exm_date == record.exm_date ): raise ValidationError(_("The room is occupied!")) @@ -280,9 +281,7 @@ def check_active(self): "Active", default="True", help="Activate/Deactivate record" ) name = fields.Char("Exam Name", required=True, help="Name of Exam") - exam_code = fields.Char( - "Exam Code", required=True, readonly=True, help="Code of exam" - ) + exam_code = fields.Char("Exam Code", readonly=True, help="Code of exam") standard_id = fields.Many2many( "standard.standard", "standard_standard_exam_rel", @@ -449,7 +448,7 @@ def _compute_color_name(self): "Additional Exam Name", required=True, help="Name of Exam" ) addtional_exam_code = fields.Char( - "Exam Code", required=True, help="Exam Code", readonly=True + "Exam Code", help="Exam Code", readonly=True ) standard_id = fields.Many2one( "school.standard", "Standard", help="Select standard for exam" @@ -597,7 +596,6 @@ def _compute_result(self): ("confirm", "Confirm"), ("re-evaluation", "Re-Evaluation"), ("re-evaluation_confirm", "Re-Evaluation Confirm"), - ("done", "Done"), ], "State", readonly=True, @@ -690,30 +688,6 @@ def result_re_evaluation(self): line.marks_reeval = line.obtain_marks rec.state = "re-evaluation" - def set_done(self): - """Method to obtain history of student""" - history_obj = self.env["student.history"] - for rec in self: - vals = { - "student_id": rec.student_id.id, - "academice_year_id": rec.student_id.year.id, - "standard_id": rec.standard_id.id, - "percentage": rec.percentage, - "result": rec.result, - } - history_rec = history_obj.search( - [ - ("student_id", "=", rec.student_id.id), - ("academice_year_id", "=", rec.student_id.year.id), - ("standard_id", "=", rec.standard_id.id), - ] - ) - if history_rec: - history_obj.write(vals) - elif not history_rec: - history_obj.create(vals) - rec.state = "done" - class ExamGradeLine(models.Model): """Defining model for Exam Grade Line.""" @@ -745,13 +719,22 @@ def _compute_grade(self): if rec.exam_id and rec.exam_id.student_id and grade_lines: for grade_id in grade_lines: b_id = rec.obtain_marks <= grade_id.to_mark - if rec.obtain_marks > 0: - if rec.obtain_marks >= grade_id.from_mark and b_id: - rec.grade_line_id = grade_id - if rec.marks_reeval and rec.obtain_marks >= 0.0: - r_id = rec.marks_reeval <= grade_id.to_mark - if rec.marks_reeval >= grade_id.from_mark and r_id: + if rec.state not in [ + "re-evaluation", + "re-evaluation_confirm", + ]: + if ( + rec.obtain_marks >= 0 + and rec.obtain_marks >= grade_id.from_mark + and b_id + ): rec.grade_line_id = grade_id + else: + if (rec.marks_reeval and rec.obtain_marks >= 0.0) and ( + rec.marks_reeval >= grade_id.from_mark + and rec.marks_reeval <= grade_id.to_mark + ): + rec.grade_line_id = grade_id.id exam_id = fields.Many2one("exam.result", "Result", help="Select exam") state = fields.Selection( @@ -830,7 +813,11 @@ def _compute_student_result(self): ) roll_no = fields.Integer("Roll No", readonly=True, help="Student rol no.") standard_id = fields.Many2one( - "school.standard", "Standard", readonly=True, help="School Standard" + "school.standard", + "Standard", + related="a_exam_id.standard_id", + store=True, + help="School Standard", ) obtain_marks = fields.Float("Obtain Marks", help="Marks obtain in exam") result = fields.Char( @@ -843,6 +830,14 @@ def _compute_student_result(self): "Active", default=True, help="Activate/Deactivate record" ) + _sql_constraints = [ + ( + "additional_exam_result_unique", + "unique(a_exam_id,student_id)", + "Student is not repeated in same exam!", + ) + ] + def _update_student_vals(self, vals): """This is the common method to update student record at creation and updation of the exam record""" @@ -872,7 +867,6 @@ def write(self, vals): @api.onchange("student_id") def onchange_student(self): """ Method to get student roll no and standard by selecting student""" - self.standard_id = self.student_id.standard_id.id self.roll_no = self.student_id.roll_no @api.constrains("obtain_marks") diff --git a/exam/report/add_exam_result.py b/exam/report/add_exam_result.py deleted file mode 100644 index f331e413..00000000 --- a/exam/report/add_exam_result.py +++ /dev/null @@ -1,46 +0,0 @@ -# See LICENSE file for full copyright and licensing details. - -import time - -from odoo import api, models - - -class ReportAddExamResult(models.AbstractModel): - _name = "report.exam.exam_result_report" - _description = "Exam result Report" - - @api.model - def _get_result_detail(self, subject_ids, result): - """Method to get result data""" - sub_list = [] - result_data = [] - for sub in subject_ids: - sub_list.append(sub.id) - sub_obj = self.env["exam.subject"] - subject_exam_ids = sub_obj.search( - [("id", "in", sub_list), ("exam_id", "=", result.id)] - ) - for subject in subject_exam_ids: - result_data.append( - { - "subject": subject.subject_id.name or "", - "max_mark": subject.maximum_marks or "", - "mini_marks": subject.minimum_marks or "", - "obt_marks": subject.obtain_marks or "", - "reval_marks": subject.marks_reeval or "", - } - ) - return result_data - - @api.model - def _get_report_values(self, docids, data=None): - """Inherited method to get report values""" - result_data = self.env["exam.result"].browse(docids) - return { - "doc_ids": docids, - "data": data, - "doc_model": "exam.result", - "docs": result_data, - "get_result_detail": self._get_result_detail, - "time": time, - } diff --git a/exam/report/additional_exam_report.xml b/exam/report/additional_exam_report.xml index f908fbc5..0ec4c2d9 100644 --- a/exam/report/additional_exam_report.xml +++ b/exam/report/additional_exam_report.xml @@ -78,7 +78,7 @@ Subject Name - Maximum marks + Maximum Marks Minimum Marks @@ -94,10 +94,10 @@ - + - + diff --git a/exam/report/batch_result_report.py b/exam/report/batch_result_report.py index e7d06f53..860d3e80 100644 --- a/exam/report/batch_result_report.py +++ b/exam/report/batch_result_report.py @@ -16,39 +16,38 @@ def pass_student(self, year, standard_id): ("state", "=", "finished"), ] ) + exam_result_rec = exam_result_pass_rec = exam_result_fail_rec = [] result_obj = self.env["exam.result"] for rec in exam_rec: - exam_result_rec = result_obj.search( + exam_result_rec += result_obj.search( [("s_exam_ids", "=", rec.id), ("state", "!=", "draft")] ) - exam_result_pass_rec = result_obj.search( + exam_result_pass_rec += result_obj.search( [ ("s_exam_ids", "=", rec.id), ("result", "=", "Pass"), ("state", "!=", "draft"), ] ) - exam_result_fail_rec = result_obj.search( + exam_result_fail_rec += result_obj.search( [ ("s_exam_ids", "=", rec.id), ("result", "=", "Fail"), ("state", "!=", "draft"), ] ) - std_pass = "" - if len(exam_result_pass_rec.ids) > 0: - # Calculate percentage of students who pass the exams - std_pass = (100 * len(exam_result_pass_rec.ids)) / len( - exam_result_rec.ids - ) - return [ - { - "student_appear": len(exam_result_rec.ids) or 0.0, - "studnets": len(exam_result_pass_rec.ids) or 0.0, - "pass_std": std_pass or 0.0, - "fail_student": len(exam_result_fail_rec.ids) or 0.0, - } - ] + std_pass = "" + if len(exam_result_pass_rec) > 0: + # Calculate percentage of students who pass the exams + std_pass = (100 * len(exam_result_pass_rec)) / len(exam_result_rec) + return [ + { + "student_appear": len(exam_result_rec) or 0.0, + "studnets": len(exam_result_pass_rec) or 0.0, + "pass_std": std_pass or 0.0, + "fail_student": len(exam_result_fail_rec) or 0.0, + } + ] @api.model def _get_report_values(self, docids, data=None): diff --git a/exam/report/result_info.py b/exam/report/result_info.py index 7ccb5d0e..04ccbd46 100644 --- a/exam/report/result_info.py +++ b/exam/report/result_info.py @@ -24,6 +24,9 @@ def get_lines(self, result_id, student): list_result = [] for sub_id in result_id: for sub in sub_id.result_ids: + obtain_mark = sub.obtain_marks + if sub_id.state in ["re-evaluation", "re-evaluation_confirm"]: + obtain_mark = sub.marks_reeval list_result.append( { "standard_id": sub_id.standard_id.standard_id.name, @@ -31,36 +34,12 @@ def get_lines(self, result_id, student): "code": sub.subject_id.code, "maximum_marks": sub.maximum_marks, "minimum_marks": sub.minimum_marks, - "obtain_marks": sub.obtain_marks, + "obtain_marks": obtain_mark, "s_exam_ids": sub_id.s_exam_ids.name, } ) return list_result - @api.model - def get_exam_data(self, result_id, student): - """Method to get the exam info of student""" - list_exam = [] - value = {} - final_total = 0 - per = 0.0 - obtain_marks = 0.0 - maximum_marks = 0.0 - for res in result_id: - obtain_marks = float( - sum(res_data.obtain_marks for res_data in res.result_ids) - ) - maximum_marks = float( - sum(res_data.obtain_marks for res_data in res.result_ids) - ) - per += obtain_marks * 100 / maximum_marks - final_total = final_total + res.total - value.update( - {"result": res.result, "percentage": per, "total": final_total} - ) - list_exam.append(value) - return list_exam - @api.model def _get_report_values(self, docids, data=None): """Inherited method to get report values""" @@ -86,5 +65,4 @@ def _get_report_values(self, docids, data=None): "data": data, "docs": docs, "get_lines": self.get_lines, - "get_exam_data": self.get_exam_data, } diff --git a/exam/report/result_information_report.xml b/exam/report/result_information_report.xml index 037d591b..aac35bb1 100644 --- a/exam/report/result_information_report.xml +++ b/exam/report/result_information_report.xml @@ -47,7 +47,7 @@ : - + @@ -74,91 +74,94 @@
- - - - - - - - - - - - - + +
- Subject Code - - Subject Name - - Maximum marks - - Minimum Marks - - Obtain Mark - - Exam -
+ - - -
- + style="font-family: 'Helvetica';font-size: 18px;border: 2px solid black;"> + Subject Code - + style="font-family: 'Helvetica';font-size: 18px;border: 2px solid black;"> + Subject Name - + style="font-family: 'Helvetica';font-size: 18px;border: 2px solid black;"> + Maximum marks - + style="font-family: 'Helvetica';font-size: 18px;border: 2px solid black;"> + Minimum Marks - + style="font-family: 'Helvetica';font-size: 18px;border: 2px solid black;"> + Obtain Mark - + style="font-family: 'Helvetica';font-size: 18px;border: 2px solid black;"> + Exam
-
-
- - - - - - - - - - + + + +
- Total - - - - Percentage - - % - - Result - - -
+ + + + + + + + +
+ + + + + + + + + + + +
+
+
+
+ + + + + + + + + +
+ Total + + + + Percentage + + % + + Result + + +
+
+
+ diff --git a/exam/views/additional_exam_report.xml b/exam/views/additional_exam_report.xml deleted file mode 100644 index 8498101e..00000000 --- a/exam/views/additional_exam_report.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - diff --git a/exam/views/batch_exam.xml b/exam/views/batch_exam.xml deleted file mode 100644 index 7d9933b3..00000000 --- a/exam/views/batch_exam.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - diff --git a/exam/views/exam_sequence.xml b/exam/views/exam_sequence.xml deleted file mode 100644 index 2714e218..00000000 --- a/exam/views/exam_sequence.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - Exam - exam.exam - %(year)s/%(month)s/ - 3 - - - - - - - Additional Exam - additional.exam - %(year)s/%(month)s/ - 3 - - - - - diff --git a/exam/views/exam_view.xml b/exam/views/exam_view.xml index bcc06b49..05b3de3f 100644 --- a/exam/views/exam_view.xml +++ b/exam/views/exam_view.xml @@ -152,8 +152,8 @@ - - + + @@ -288,8 +288,7 @@