I need to print subjects and marks.but its not iterated and Showing an error like this. TypeError: 'NoneType' object is not subscriptable. I am calling python function for that and the code is added here:
from odoo import api, fields, models class StudentProgressReport(models.AbstractModel):
_name = 'report.student_details.report_student_progress'
@api.model
def _get_report_values(self, docids, data=None):
print("docids",docids)
subjects = self.env['student.subject.lines'].search([('subject_line','=',name.id)])
student_subject_line = []
for info in subjects:
vals={
'subject_line':info.subject_line,
'subject':info.subject.name,
'marks':info.marks
}
student_subject_line.append(vals)
print(info.subject_line)
print(info.subject.name)
print("subjects",subjects)
print("student_subject_line",student_subject_line)
return {
'doc_model': 'student.subject.lines',
'subjects': subjects,
'student_subject_line':student_subject_line
}
xml code is:
<tr>
<td style="padding:5px 50px 0px 5px;background-color:#E0E0E0;"> <p style="text-align:right;"><strong>Teacher Name:</strong></p></td>
<td style="padding:5px 50px 0px 5px;background-color:#E0E0E0;">
<t t-esc="doc.teacher_name"/>
</td>
</tr>
</table>
<br></br>
<table class="table table condensed" style="border: 3px solid black !important;">
<t t-set="student_name" t-value="0"/>
<tr t-foreach='doc.classroom_lines' t-as='line'>
<td style="padding:5px 50px 0px 5px;background-color:#E0E0E0;">
<p style="text-align:right;"><strong>Student Name:</strong></p></td>
<td style="padding:5px 50px 0px 5px;background-color:#E0E0E0;">
<span t-esc="line.student_name.name"/>
<t t-foreach="student_subject_line" t-as="info[]">
<t t-if="info['subject_line']=='line.subject_id'">
<tr t-att-class="'bg-200 font-weight-bold o_line_section'">
<td>
<t t-esc="info['subject']"/>
</td>
<td>
<t t-esc="info['marks']"/>
</td>
</tr>
</t>
</t>
</td>
</tr>
</table>
and python code is: class classroom_details(models.Model): _name = 'classroom.details'
teacher_name = fields.Char('Name of the Teacher')
classroom_lines = fields.One2many('class.room', 'subject_id','Subject List')
class classroom(models.Model): _name = 'class.room'
subject_id = fields.Many2one('classroom.details')
student_name = fields.Many2one('student.details', string='Student Name')
student_subject_line = fields.One2many('student.subject.lines','subject_line')
class Student_Subject(models.Model): _name = 'student.subject.lines'
subject_line = fields.Many2one('class.room')
subject = fields.Many2one("subject.master", string='Subject')
marks = fields.Float ('Marks')
I am new in odoo.please help me to solve this.