assignment_report.xml file
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="assignments_report.assignment_report">
<style>
.font{
font-size:14px;
font-family:"Helvetica"
}
@page{
margin-top:1%;
size: A4;
}
</style>
<t t-call="web.html_container">
<t t-call="web.external_layout">
<div class="font">
<div class="page">
<t t-foreach="get_objects(docs)" t-as="objs">
<t t-foreach="objs" t-as="obj">
<div class="text-center">
<h2>
Assignment Report
</h2>
</div>
<br></br>
<br></br>
<t>
<table width="100%">
<tbody>
<tr>
<td
width="17%">
<b>Teacher
</b>
</td>
<td>
:
<span
t-raw="'%s' % obj.assignment_id.faculty_id.name if obj.assignment_id.faculty_id.name else ''"/>
</td>
<td
width="15%">
<b>Subject
</b>
</td>
<td>
:
<span
t-raw="'%s' % obj.assignment_id.subject_id.name if obj.assignment_id.subject_id.name else ''"/>
</td>
</tr>
</tbody>
</table>
<br></br>
<br></br>
<table
class="table table-bordered">
<thead>
<th
class="text-center">SNO
</th>
<th
class="text-center">Name of Student
</th>
<th
class="text-center">CW
</th>
<th
class="text-center">HW
</th>
<th
class="text-center">PROJECT
</th>
<th
class="text-center">QUIZ1
</th>
<th
class="text-center">QUIZ2
</th>
<th
class="text-center">QUIZ3
</th>
<th
class="text-center">UT
</th>
<th
class="text-center">FINAL
</th>
</thead>
<tbody>
<t t-foreach="get_lines(obj)" t-as="lines">
<tr>
<td class="text-center">
<span t-esc="obj_index+1"/>
</td>
<td class="text-left">
<span t-raw="'%s' % obj.student_id.name if obj.student_id.name else ''"/>
<span t-raw="'%s' % obj.assignment_id.assignment_type_id.name if obj.assignment_id.assignment_type_id.name else ''"/>
</td>
<td class="text-right" t-if="obj.assignment_id.assignment_type_id.name == 'Assignment-1' ">
<span t-raw="'%s' % obj.marks if obj.marks else ''"/>
</td>
<td
class="text-right" t-if="obj.assignment_id.assignment_type_id.name == 'Assignment-2' ">
<span
t-raw="'%s' % obj.marks if obj.marks else ''"/>
</td>
<td class="text-right" t-if="obj.assignment_id.assignment_type_id.name == 'Assignment-2' ">
<span t-raw="'%s' % Assignment_2(obj) if Assignment_2(obj) else ''"/>
</td>
<!--
<td class="text-right" t-if="lines.assignment_type_id == 'Assignment-2' ">
<span
t-raw="'%s' % result.marks if result.marks else ''"/>
</td>
<td class="text-right" t-if="lines.assignment_type_id == 'Assignment-2' ">
<span
t-raw="'%s' % result.marks if result.marks else ''"/>
</td>
<td
class="text-right" t-if="lines.assignment_type_id == 'Assignment-2' ">
<span
t-raw="'%s' % result.marks if result.marks else ''"/>
</td>
<td
class="text-right" t-if="lines.assignment_type_id == 'Assignment-2' ">
<span
t-raw="'%s' % result.marks if result.marks else ''"/>
</td>
<td class="text-right" t-if="lines.assignment_type_id == 'Assignment-2' ">
<span
t-raw="'%s' % get_total(get_lines(obj)) if get_total(get_lines(obj)) else ''"/>
</td>-->
</tr>
</t>
</tbody>
</table>
<br></br>
<br></br>
</t>
<p style="page-break-after: always;"></p>
</t>
</t>
</div>
</div>
</t>
</t>
</template>
</data>
</odoo>
assignment_report.py
# -*- coding: utf-8 -*-
###############################################################################
#
# Tech-Receptives Solutions Pvt. Ltd.
# 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 Lesser General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
import time
from odoo import models, api, fields
from odoo.addons.openeducat_assignment.models import assignment_sub_line
class ReportAssignmentReport(models.AbstractModel):
_name = "report.assignments_report.assignment_report"
_template = " report.assignment_report"
_description = "assignments Report"
def get_objects(self, objects):
obj = []
for object in objects:
obj.extend(object)
return obj
def get_lines(self, obj):
lines = []
for line in obj.assignment_sub_line:
lines.extend(line)
return lines
def get_date(self, date):
date1 = fields.Date.to_date(date)
return str(date1.month) + ' / ' + str(date1.year)
def get_total(self, assignment_sub_line):
total = [x.student_id.marks for x in assignment_sub_line]
return sum(total)
def Assignment_1(self, lines):
cw = []
for line in lines:
if line.assignment_type_id.name == 'Assignment_1':
marks = [x.marks for x in line]
cw.extend(marks)
return cw
def Assignment_2(self, lines):
hw = []
for line in lines:
if line.assignment_type_id.name == 'Assignment_2':
marks = [x.marks for x in line]
hw.extend(marks)
return hw
@api.model
def _get_report_values(self, docids, data=None):
docs = self.env['op.assignment.sub.line'].browse(docids)
docargs = {
'doc_model': 'op.assignment.sub.line',
'docs': docs,
'time': time,
'get_objects': self.get_objects,
'get_lines': self.get_lines,
'get_date': self.get_date,
'get_total': self.get_total,
'Assignment_1': self.Assignment_1,
'Assignment_2': self.Assignment_2,
}
return docargs
please help me to solve thismy methods are not returning any thing why?????