report student of course

This commit is contained in:
XuanHuyen
2025-04-05 08:47:50 +07:00
parent bfc818f7a6
commit 2858a7cf50
5 changed files with 64 additions and 0 deletions
+2
View File
@@ -24,6 +24,8 @@ Academy Management
'data': [
'security/ir.model.access.csv',
'security/academy_security.xml',
'reports/student_report_template.xml',
'reports/student_report.xml',
'data/ir_sequence_data.xml',
'views/academy_course_views.xml',
'views/academy_schedule_views.xml',
@@ -7,6 +7,7 @@ class AcademyCourse(models.Model):
name = fields.Char(string='Tên khóa học', required=True)
code = fields.Char(string='Mã khóa học', required=True, copy=False, readonly=True, default=lambda self: _(' '))
description = fields.Text(string='Mô tả khóa học')
student_ids = fields.Many2many('academy.student', string='Học sinh đăng ký')
_sql_constraints = [(
'code_unique',
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="report_student_course" model="ir.actions.report">
<field name="name">Báo cáo DS học sinh đăng ký</field>
<field name="model">academy.course</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">academy_management.report_student_template</field>
<field name="report_file">academy_management.report_student_template</field>
<field name="binding_model_id" ref="academy_management.model_academy_course" />
<field name="binding_type">report</field>
</record>
</odoo>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_student_template">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="web.external_layout">
<div class="page">
<h2 style="text-align: center;">Danh sách học sinh đăng ký khóa học: <t
t-esc="doc.name" /></h2>
<table class="table table-bordered" style="width: 100%;">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
</tr>
</thead>
<tbody>
<t t-foreach="doc.student_ids" t-as="student">
<tr>
<td>
<t t-esc="student_index + 1" />
</td>
<td>
<t t-esc="student.name" />
</td>
<td>
<t t-esc="student.email" />
</td>
<td>
<t t-esc="student.phone" />
</td>
</tr>
</t>
</tbody>
</table>
</div>
</t>
</t>
</t>
</template>
</odoo>
@@ -11,6 +11,7 @@
<field name="name" />
<field name="code" />
<field name="description" />
<field name="student_ids" widget="many2many_tags" />
</group>
</sheet>
</form>
@@ -24,6 +25,7 @@
<list string="">
<field name="name" />
<field name="code" />
<field name="student_ids" widget="many2many_tags" />
</list>
</field>
</record>