Skip to Content
Menu
This question has been flagged
2 Replies
2055 Views

I want to create a report for get list of attendance within date periods . I used wizard for it.

as a  first step , I tried

after submit form print all attendance.

report is generated succesfully but no data in the pdf.


please help me how to pass data to report

wizard folder

create_food_allowance.py


class createreport(models.Model):
_name = 'lankaspin_allowances.createreport'
_description = 'Create Food Allowance Wizard'

start_date = fields.Date('Start Date')
end_date= fields.Date('End Date')

def print_report(self):
data = {
'model': 'lankaspin_allowances.createreport',
'form': self.read()[0]
}
print(data['form']['start_date'])
attendence = self.env['hr.attendance'].search([])
attendence_list = []
for app in attendence:
vals = {
'check_in': app.check_in,
'check_out': app.check_out,
}
attendence_list.append(vals)
data['attendence'] =attendence_list
print(data)

return self.env.ref('lankaspin_allowances.food_allowance_report').with_context(landscape=True).report_action(self, data=data)





Report folder

report template


<template id="print_food_allowance_report">
<t t-call="web.html_container">
<t t-call="web.external_layout">
<div class="page">
<div class="oe_structure"/>
<div class="row">
<table class="table ">
<thead>
<tr>
<th style="text-align:left;"><strong>Check_in</strong></th>
<th style="text-align:left;"><strong>Check_out </strong></th>
<th style="text-align:left;"><strong>Signature</strong></th>
</tr>
</thead>
<tbody>
<t t-foreach="attendence" t-as="o">
<tr>
<td style="text-align:left;">
<t t-esc="o['check_in']"/>
</td>
<td style="text-align:left;">
<t t-esc="o['check_out']"/>
</td>
<td style="text-align:left;">
sss
</td>
</tr>
</t>
<tr>
<td style="text-align:left;">
shah
</td>
<td style="text-align:left;">
dddd
</td>
<td style="text-align:left;">
sss
</td>
</tr>
</tbody>
</table>
</div>
</div>
</t>
</t>
</template>


report menu


<report
id="food_allowance_report"
string="Appointment"
model="lankaspin_allowances.createreport"
report_type="qweb-pdf"
name="lankaspin_allowances.print_food_allowance_report"
file="lankaspin_allowances.print_food_allowance_report"/>

Avatar
Discard
Best Answer

Hi, 

Please add a python file in your custom module and add the following code,

class ClassName (models.AbstractModel): 
_name = 'report.module_name.print_food_allowance_report'

    @ api.model
    def _get_report_values ( self , docids , data = None ):
        data = {}
        return {'data' : data}

Muhammed Ali M -  iWesabe

Avatar
Discard
Best Answer
_name = 'report.attendance_report.report_attendance_branch_template'

@api.model
def get_report_values(self, docids, data=None):
if not data.get('form'):
raise UserError(_("Form content is missing, this report cannot be printed."))
return {
'data': data.get('form'),
use this way to get the data
Avatar
Discard
Related Posts Replies Views Activity
3
Dec 20
1922
1
Feb 20
2135
1
Oct 19
1717
0
Mar 22
1525
2
Oct 20
26817