Skip to content

Commit

Permalink
[ADD] changed code to new api of following objects
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharth committed Jun 19, 2015
1 parent 267f31b commit 419955e
Show file tree
Hide file tree
Showing 26 changed files with 499 additions and 460 deletions.
7 changes: 4 additions & 3 deletions openeducat_erp/op_result_line/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
#/#############################################################################
###############################################################################
#
# Tech-Receptives Solutions Pvt. Ltd.
# Copyright (C) 2004-TODAY Tech-Receptives(<http://www.tech-receptives.com>).
# Copyright (C) 2009-TODAY Tech-Receptives(<http://www.techreceptives.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
Expand All @@ -17,7 +17,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#/#############################################################################
###############################################################################

import op_result_line


Expand Down
36 changes: 19 additions & 17 deletions openeducat_erp/op_result_line/op_result_line.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
#/#############################################################################
###############################################################################
#
# Tech-Receptives Solutions Pvt. Ltd.
# Copyright (C) 2004-TODAY Tech-Receptives(<http://www.tech-receptives.com>).
# Copyright (C) 2009-TODAY Tech-Receptives(<http://www.techreceptives.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
Expand All @@ -17,24 +17,26 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#/#############################################################################
from openerp.osv import osv, fields
###############################################################################

class op_result_line(osv.osv):
from openerp import models, fields


class op_result_line(models.Model):
_name = 'op.result.line'
_rec_name = 'marks'

_columns = {
'marksheet_line_id': fields.many2one('op.marksheet.line', string='Marksheet Line'),
'exam_id': fields.many2one('op.exam', string='Exam', required=True),
'exam_tmpl_id':fields.many2one('op.result.exam.line','Exam Template'),
'marks': fields.float(string='Marks', required=True),
'per': fields.float(string='Percentage', required=True),
'student_id': fields.many2one('op.student', string='Student', required=True),
'status': fields.selection([('p','Pass'),('f','Fail')], string='Status', required=True),
'result_id':fields.many2one('op.marksheet.line','MarkSheet Line'),
'total_marks': fields.float(string='Percentage'),
}
marksheet_line_id = fields.Many2one(
'op.marksheet.line', 'Marksheet Line')
exam_id = fields.Many2one('op.exam', 'Exam', required=True)
exam_tmpl_id = fields.Many2one('op.result.exam.line', 'Exam Template')
marks = fields.Float('Marks', required=True)
per = fields.Float('Percentage', required=True)
student_id = fields.Many2one('op.student', 'Student', required=True)
status = fields.Selection(
[('p', 'Pass'), ('f', 'Fail')], 'Status', required=True)
result_id = fields.Many2one('op.marksheet.line', 'MarkSheet Line')
total_marks = fields.Float('Percentage')


op_result_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
7 changes: 4 additions & 3 deletions openeducat_erp/op_result_template/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
#/#############################################################################
###############################################################################
#
# Tech-Receptives Solutions Pvt. Ltd.
# Copyright (C) 2004-TODAY Tech-Receptives(<http://www.tech-receptives.com>).
# Copyright (C) 2009-TODAY Tech-Receptives(<http://www.techreceptives.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
Expand All @@ -17,7 +17,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#/#############################################################################
###############################################################################

import op_result_template


Expand Down
207 changes: 95 additions & 112 deletions openeducat_erp/op_result_template/op_result_template.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
#/#############################################################################
###############################################################################
#
# Tech-Receptives Solutions Pvt. Ltd.
# Copyright (C) 2004-TODAY Tech-Receptives(<http://www.tech-receptives.com>).
# Copyright (C) 2009-TODAY Tech-Receptives(<http://www.techreceptives.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
Expand All @@ -17,32 +17,36 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#/#############################################################################
from openerp.osv import osv,fields
###############################################################################
import time
class op_result_template(osv.osv):

from openerp import models, fields, api


class op_result_template(models.Model):
_name = 'op.result.template'
_description = 'Result Template'

_rec_name = 'name'
_columns = {
'exam_session_id':fields.many2one('op.exam.session','Exam Session', required=True),
'name':fields.char("Name", size=254, required=True),
'result_date':fields.date('Result Date', required=True),
'line_ids':fields.one2many('op.result.template.line', 'result_id', 'Lines'),
'criteria_ids':fields.many2many('op.min.clear.criteria','op_res_tmp_crirel','res_id','cri_id','Minimum qualification Criteria'),
'pass_status_ids':fields.many2many('op.pass.status','op_res_pass_st_rel','res_id','pass_id','Pass Status')

}
def genrate_result(self, cr, uid, ids, context={}):
for self_obj in self.browse(cr, uid, ids, context=context):

marksheet_reg_id = self.pool.get('op.marksheet.register').create(cr, uid, {
'name':'Mark Sheet for %s'%self_obj.exam_session_id.name,
'exam_session_id':self_obj.exam_session_id.id,
'generated_date':time.strftime("%Y-%m-%d"),
'generated_by':uid,
'status':'d',

exam_session_id = fields.Many2one(
'op.exam.session', 'Exam Session', required=True)
name = fields.Char("Name", size=254, required=True)
result_date = fields.Date('Result Date', required=True)
line_ids = fields.One2many('op.result.template.line', 'result_id', 'Lines')
criteria_ids = fields.Many2many(
'op.min.clear.criteria', 'op_res_tmp_crirel', 'res_id', 'cri_id', 'Minimum qualification Criteria')
pass_status_ids = fields.Many2many(
'op.pass.status', 'op_res_pass_st_rel', 'res_id', 'pass_id', 'Pass Status')

@api.one
def genrate_result(self):
for self_obj in self:
marksheet_reg_id = self.env['op.marksheet.register'].create({
'name': 'Mark Sheet for %s' % self_obj.exam_session_id.name,
'exam_session_id': self_obj.exam_session_id.id,
'generated_date': time.strftime("%Y-%m-%d"),
'generated_by': uid,
'status': 'd',
})
stu_lst = []
for exam_session in self_obj.line_ids:
Expand All @@ -53,27 +57,27 @@ def genrate_result(self, cr, uid, ids, context={}):

for attd in exam.exam_id.attendees_line:
result_dict = {
'exam_id':exam.exam_id.id,
'exam_tmpl_id':exam.id,
'marks':(exam.weightage/100)*attd.marks,
'status':attd.marks >= exam.pass_marks and 'p' or 'f',
'per':(100*attd.marks)/exam.total_marks,
'student_id':attd.student_id.id,
'total_marks': (exam.weightage/100)*exam.total_marks,
'exam_id': exam.exam_id.id,
'exam_tmpl_id': exam.id,
'marks': (exam.weightage / 100) * attd.marks,
'status': attd.marks >= exam.pass_marks and 'p' or 'f',
'per': (100 * attd.marks) / exam.total_marks,
'student_id': attd.student_id.id,
'total_marks': (exam.weightage / 100) * exam.total_marks,
}
ret_id = self.pool.get('op.result.line').create(cr, uid, result_dict, context=context)
stu_lst.append([ret_id,attd.student_id.id,result_dict])
ret_id = self.env['op.result.line'].create(result_dict)
stu_lst.append(
[ret_id, attd.student_id.id, result_dict])
stu_dict = {}
for ret_id,stu_id,data in stu_lst:
if stu_id not in stu_dict:
for ret_id, stu_id, data in stu_lst:
if stu_id not in stu_dict:
stu_dict[stu_id] = []

stu_dict[stu_id].append([ret_id,data])
stu_dict[stu_id].append([ret_id, data])
for stu_id in stu_dict:


total_marks = sum([x[1]['marks'] for x in stu_dict[stu_id]])
per = (total_exam and (100/total_exam)*total_marks) or 0.0
per = (total_exam and (100 / total_exam) * total_marks) or 0.0
result = ''
pass_flg = True
number_fail = 0
Expand All @@ -93,114 +97,93 @@ def genrate_result(self, cr, uid, ids, context={}):
to_consider = pass_st

if to_consider:
result = to_consider.result
result = to_consider.result
else:
crit_ids = self_obj.criteria_ids
to_consider = False
max_pass = False
for crit_id in crit_ids:
if crit_id.number == number_fail:
to_consider = crit_id
if not max_pass or crit_id.number > max_pass.number:
if not max_pass or crit_id.number > max_pass.number:
max_pass = crit_id
if not to_consider:
to_consider = max_pass
result = to_consider.result

mark_line_id = self.pool.get('op.marksheet.line').create(cr, uid,
{'student_id':stu_id,
'marksheet_reg_id':marksheet_reg_id,
'exam_session_id':exam_session.id,
'result':result,
'total_marks': total_marks,
'total_per': per,
'total_exam_marks':total_exam,
}
)
self.pool.get('op.result.line').write(cr, uid, [x[0] for x in stu_dict[stu_id]], {'result_id':mark_line_id,
})
mark_line_id = self.env['op.marksheet.line'].create({'student_id': stu_id,
'marksheet_reg_id': marksheet_reg_id,
'exam_session_id': exam_session.id,
'result': result,
'total_marks': total_marks,
'total_per': per,
'total_exam_marks': total_exam,
})
self.env['op.result.line'].write(
[x[0] for x in stu_dict[stu_id]], {'result_id': mark_line_id, })
return True


op_result_template()

class op_result_template_line(osv.osv):
class op_result_template_line(models.Model):
_name = 'op.result.template.line'
_rec_name = 'exam_session_id'
_description = 'Result template Line'

_columns = {
'exam_session_id':fields.many2one('op.exam.session','Exam Session'),
'detailed_report':fields.boolean('Detailed Report'),
'course_id': fields.related('exam_session_id', 'course_id', type='many2one', relation='op.course',
string='Course', readonly=True ),
'batch_id': fields.related('exam_session_id', 'batch_id', type='many2one', relation='op.batch',
string='Batch', readonly=True ),
'standard_id':fields.related('exam_session_id', 'standard_id', type='many2one',
relation='op.standard', string="Standard", readonly=True),
'division_id': fields.related('exam_session_id', 'division_id', type='many2one', relation='op.division',
string='Division', readonly=True ),
'result_id':fields.many2one('op.result.template','Result Template Line'),
'exam_lines':fields.one2many('op.result.exam.line', 'result_id', 'Exam Lines'),
}
def onchange_exam_session(self, cr, uid, ids, exam_session_id, context={}):
exam_session_id = fields.Many2one('op.exam.session', 'Exam Session')
detailed_report = fields.Boolean('Detailed Report')
course_id = fields.Many2one(
'course_id', 'Course', related='exam_session_id.course_id', readonly=True)
batch_id = fields.Many2one(
'batch_id', 'Batch', related='exam_session_id.batch_id', readonly=True)
standard_id = fields.Many2one(
'standard_id', 'Standard', related='exam_session_id.standard_id', readonly=True)
division_id = fields.Many2one(
'division_id', 'Division', related='exam_session_id.division_id', readonly=True)
result_id = fields.Many2one('op.result.template', 'Result Template Line')
exam_lines = fields.One2many(
'op.result.exam.line', 'result_id', 'Exam Lines')

@api.multi
def onchange_exam_session(exam_session_id):
ret_val = []
exam_session_pool = self.pool.get('op.exam.session')
exam_session_obj = exam_session_pool.browse(cr, uid, exam_session_id, context=context)
exam_session_pool = self.env['op.exam.session']
exam_session_obj = exam_session_pool.browse(exam_session_id)
for exam_obj in exam_session_obj.exam_ids:
ret_val.append({'exam_id':exam_obj.id,'weightage':100})
ret_val.append({'exam_id': exam_obj.id, 'weightage': 100})

return {'value':{'exam_lines':ret_val}}
return {'value': {'exam_lines': ret_val}}

op_result_template_line()

class op_result_exam_line(osv.osv):
class op_result_exam_line(models.Model):
_name = 'op.result.exam.line'
_description = 'Result Exam Line'

_columns = {
'result_id':fields.many2one('op.result.template.line'),
'exam_id':fields.many2one('op.exam', 'Exam'),
'pass_marks':fields.related('exam_id',
'min_marks',
type='float',
string='Passing Marks',
readonly=True),
'total_marks':fields.related('exam_id',
'total_marks',
type='float',
string='Total Marks',
readonly=True),
'weightage':fields.float('Weightage'),
'result_lines':fields.one2many("op.result.line",
"exam_tmpl_id",
"Result Lines"),
}

op_result_exam_line()

class op_min_clearance_criteria(osv.osv):
result_id = fields.Many2one('op.result.template.line')
exam_id = fields.Many2one('op.exam', 'Exam')
pass_marks = fields.Float(
'min_marks', 'Passing Marks', related='exam_id.min_marks', readonly=True)
total_marks = fields.Float(
related='exam_id.total_marks', string='Total Marks', readonly=True)
weightage = fields.Float('Weightage')
result_lines = fields.One2many(
'op.result.line', 'exam_tmpl_id', 'Result Lines')


class op_min_clearance_criteria(models.Model):
_name = "op.min.clear.criteria"
_columns = {
'name':fields.char('Name', size=256),
'number':fields.float('Number of Failed Subject'),
'result':fields.char('Result to display'),
}

op_min_clearance_criteria()
name = fields.Char('Name', size=256)
number = fields.Float('Number of Failed Subject')
result = fields.Char('Result to display')

class op_pass_status(osv.osv):

class op_pass_status(models.Model):
_name = 'op.pass.status'
_description = 'Pass Status'

_columns = {
'name':fields.char('Name', size=256),
'number':fields.float('Minimum Percentage'),
'result':fields.char('Result to display'),
}

op_pass_status()
name = fields.Char('Name', size=256)
number = fields.Float('Minimum Percentage')
result = fields.Char('Result to display')


# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
8 changes: 5 additions & 3 deletions openeducat_erp/op_roll_number/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
#/#############################################################################
# -*- coding: utf-8 -*-
###############################################################################
#
# Tech-Receptives Solutions Pvt. Ltd.
# Copyright (C) 2004-TODAY Tech-Receptives(<http://www.tech-receptives.com>).
# Copyright (C) 2009-TODAY Tech-Receptives(<http://www.techreceptives.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
Expand All @@ -17,7 +18,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#/#############################################################################
###############################################################################

import op_roll_number


Expand Down
Loading

0 comments on commit 419955e

Please sign in to comment.