私の施設のニーズに合わせて、Odoo OpenEduCat試験モジュールを変更しています。そのために、以下のようにコードを調整しました。しかし、生成ボタンをクリックすると、odooは予想されるシングルトンエラーを発生させます。Odoo:ValueError( "期待されるシングルトン:%s"%self)
ファイル:Generating button Error details
--Pythonは
from openerp import models, fields, api
class OpResultTemplate(models.Model):
_name = 'op.result.template'
_description = 'Result Template'
_rec_name = 'name'
exam_session_id = fields.Many2one(
'op.exam.session', 'Exam Session', related='line_ids.exam_session_id', required=False)
name = fields.Char("Name", size=254, required=True)
result_date = fields.Date(
'Result Date', required=True, default=fields.Date.today())
line_ids = fields.One2many(
'op.result.template.line', 'result_id', 'Session Lines')
####this is for semester
inter1_ids = fields.One2many(
'op.internal1', 'result_id', 'Internal 01')
inter2_ids = fields.One2many(
'op.internal2', 'result_id', 'Internal 02')
model_ids = fields.One2many(
'op.model', 'result_id', 'Model')
final_ids = fields.One2many(
'op.final', 'result_id', 'Semester')
state = fields.Selection(
[('normal', 'Normal'), ('semester', 'Semester')],
string='State', required=True, default='normal')
# pass_status_ids = fields.Many2many('op.pass.status', string='Pass Status')
@api.one
def generate_result(self):
data = self.read(['state'])[0]
if data['state'] == 'normal' :
####Write information in to Marksheet Register the place where result generate to.
marksheet_reg_id = self.env['op.marksheet.register'].create({
'name': 'Mark Sheet for %s' % self.line_ids.exam_session_id.name,
'exam_session_id': self.line_ids.exam_session_id.id,
'generated_date': fields.Date.today(),
'generated_by': self.env.uid,
'status': 'draft',
'course_id': self.line_ids.exam_session_id.course_id.name,
'batch_id': self.line_ids.exam_session_id.batch_id.name,
'exam_type': self.line_ids.exam_session_id.exam_type.name,
'semester_id': self.line_ids.exam_session_id.semester_id.name,
})
student_list = []####Define array to store
for exam_session in self.line_ids:####line_ids is table that located in Result generator which allow to choose exam session
total_exam = 0.0#global var
for exam in exam_session.exam_session_id:####exam_session.exam_lines is the table that list the exam or subject located in Result generator->Exam session
total_exam += exam.exam_ids.total_marks
for attd in exam.exam_ids.attendees_line:####exam.exam_id.attendees_line location that contant student name and mark in each subject
result_dict = {####this loop is to write information to result line
'exam_id': exam.exam_ids.id,
'exam_tmpl_id': exam.exam_ids.id,
'marks': attd.marks,####IMPORTANCE mark that student get in each subject THIS IS WHERE TO APPLY PERCENTAGES
'status': attd.marks >= exam.exam_ids.min_marks and####IMPORTANCE take the mark and decide pass or fail base on passing mark in each subject
'pass' or 'fail',
'per': (100 * attd.marks)/exam.exam_ids.total_marks,####NOT IMPORTANCE this can be delete, this take the mark student get and find the percentage of the subject student get in each subject
'student_id': attd.student_id.id,####student name
'total_marks': exam.exam_ids.total_marks,####the total mark of each subject that have been enter when created subject for exam
}
--Error details--
Odooサーバのエラー
トレースバック(最新の呼び出しの最後)
をcode-- "/home/v4d/odoo/openerp/http.py"、行650、_handle_exceptionで 戻るsupeディスパッチ 結果= self._call_function(** self.params)におけるR(JsonRequest、自己)._ handle_exceptionは(例外)ファイル "/home/v4d/odoo/openerp/http.py"、ライン687、
ファイル "/home/v4d/odoo/openerp/http.py"、ライン323、_call_functionで リターンchecked_call(self.db、* argsを、** kwargsから)
ファイル「/ホーム/ V4D/"/home/v4d/odoo/openerp/http.py"、lin( "/home/v4d/odoo/openerp/http.py")ファイルを "/home/v4d/odoo/openerp/http.py"に置き換えます。 コール リターン自己の電子316、checked_callで 結果= self.endpoint(*、**キロワット)
ファイル "/home/v4d/odoo/openerp/http.py"、行966、。 response_wrap 応答メソッド(引数*、** KW)
ファイル "/home/v4d/odoo/openerp/http.py"、ライン516、= F(*引数、** KW)
ファイル "/home/v4d/odoo/addons/web/controllers/main.py"、899行目、call_button action = self._call_kw(モデル、メソッド、引数、{})
ファイル "/home/v4d/odoo/addons/web/controllers/main.py"、887行目、_call_kw getattr(request.registry.get(model)、method)を返します(request.cr、request.uid 、* argsを、** kwargsから)
ファイル "/home/v4d/odoo/openerp/api.py"、ライン250、old_api返し ラッパー(自己中、* argsを、** kwargsから)
old_api 結果に "/home/v4d/odoo/openerp/api.py"、ライン421を、ファイル= new_api(RECS、* argsを、** kwargsから)
ファイル「/ホーム/ V4D/odoo/openerp/api.py "、425行目、new_api result = [method(rec、* args、** kw generate_result total_exam + = exam.exam_ids.total_marks
ファイルに自己でRECための引数)]
ファイル "/home/v4d/odoo/addons/openeducat_exam/models/result_template.py"、ライン71、 "/home/v4d/odoo/openerp/fields.py"、行821、で レコードを取得します。ensure_one()
ファイル "/home/v4d/odoo/openerp/models.py"、ライン5432、ensure_one に( "期待シングルトン:%s" は%の自己)ValueErrorを送出し
とValueError:期待シングルトンを:op.exam(44,45,46)
私はインターネット上で見つかる可能性のある他のソリューションを試しましたが、動作していないようです。どうぞお気軽にお手伝いください。事前に感謝します。ここで
試してみました。どうもありがとうございます。 – Sokunthaneth