Hello dlsuarez,
step 1 create report template using template tag
example like
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_student_master_qweb">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="report.external_layout">
<div class="page">
<div class="oe_structure"/>
<div class="row">
<span class="text-center"><h1>Student Information</h1></span>
<table class="table table condensed">
<tr>
<td><h3><strong>GRN No:</strong></h3></td>
<td><h3 t-field="o.code"/></td>
</tr>
<tr>
<td><h3><strong>First Name:</strong></h3></td>
<td><h3 t-field="o.fname"/></td>
</tr>
<tr>
<td><h3><strong>Middle Name:</strong></h3></td>
<td><h3 t-field="o.mname"/></td>
</tr>
<tr t-if="o.lname">
<td><h3><strong>Last Name:</strong></h3></td>
<td><h3 t-field="o.lname"/></td>
</tr>
<tr t-if="o.gender">
<td><h3><strong>Gender:</strong></h3></td>
<td><h3 t-field="o.gender"/></td>
</tr>
<tr t-if="o.dob">
<td><h3><strong>Date of Birth:</strong></h3></td>
<td><h3 t-field="o.dob"/></td>
</tr>
<tr t-if="o.join_date">
<td><h3><strong>Joining Date:</strong></h3></td>
<td><h3 t-field="o.join_date"/></td>
</tr>
</table>
</div>
</div>
</t>
</t>
</t>
</template>
</data>
</openerp>
step 2 registration that report using report tag
example like
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report id="school_management_qweb_report"
string="school Management Report Qweb"
model="student.master"
report_type = "qweb-pdf"
file="school_management.report_student_master_qweb"
name="school_management.report_student_master_qweb" />
</data>
</openerp>
step 3 create py file of wizard.
example like
from openerp.osv import orm, fields
from openerp.tools.translate import _
class wiz_student_report(orm.TransientModel):
_name = 'wiz.student.report'
_columns = {
'student_id': fields.many2one('student.master', 'Student Name'),
'birth_sdate': fields.date('Start Date'),
'birth_edate': fields.date('End Date'),
}
def student_report(self, cr, uid, ids, context=None):
student_obj = self.pool.get('student.master')
cur_obj = self.browse(cr, uid, ids, context=context)
datas = {}
if cur_obj.birth_sdate >= cur_obj.birth_edate:
raise orm.except_orm(_('Warning!'),_('End date is %s must be greater then start date is %s') % (cur_obj.birth_edate,cur_obj.birth_sdate))
student_ids = student_obj.search(cr, uid, [('fname', '=', cur_obj.student_id.fname),('dob','>=',cur_obj.birth_sdate),('dob','<=',cur_obj.birth_edate)], context=context)
if student_ids:
data = self.read(cr, uid, ids, context=context)[0]
datas = {
'ids': student_ids,
'model': 'wiz.student.report', # wizard model name
'form': data,
'context':context
}
return {
'type': 'ir.actions.report.xml',
'report_name': 'school_management.report_student_master_qweb',#module name.report template name
'datas': datas,
}
step 4 create xml file of wizard
example like
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="wiz_student_report_form">
<field name="name">wiz.student.report.form</field>
<field name="model">wiz.student.report</field>
<field name="arch" type="xml">
<form string="Student Report">
<group>
<group string="Student Name">
<field name="student_id" nolabel="1" options="{'no_create': True}" required="1"/>
</group>
</group>
<group string="Birth Date Between" col="4" colspan="4">
<field name="birth_sdate" required="1"/>
<field name="birth_edate" required="1"/>
</group>
<footer>
<button string="Report" name="student_report" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="wiz_student_report_action">
<field name="name">Student Wize Report</field>
<field name="res_model">wiz.student.report</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>
step 5 put this code in view xml file for pop up the wizard using button click.
example like
<button name="%(wiz_student_report_action)d" string="Student Wize Report" type="action"/>
if you find this answer helpful, please give me a thumbs up vote
Regards,
Ankit H Gandhi