On my report ,I need to print current value params of m2o field that passing on wizard :
my wizard class :
date_from = fields.Date('From')
date_to = fields.Date('To')
state_id = fields.Many2one('country.state', string='State')
localaty_id = fields.Many2one('country.localaty', string='Localaty')
my func report :
def get_request_data(self, data):
date_from = data['form']['date_from']
date_to = data['form']['date_to']
state = data['form']['state_id'][0]
localaty = data['form']['localaty_id'][0]
result = []
records = self.pool.get('app.request')
recs = records.search(self.cr, self.uid,['|',('req_date', '>=', date_from) ,( 'req_date','<=',date_to),('state_id.id','=',state), ('localaty_id.id','=',localaty)])
for rec in records.browse(self.cr,self.uid,recs):
vals = {
'number': rec.number,
'date': rec.req_date,
'subject': rec.subject,
'state': rec.state_id.name,
'localaty': rec.localaty_id.name,
'person': rec.req_person.name,
'status': rec.status
}
result.append(vals)
return result
my template :
<tr><p align="center"><b>Requests Reprot</b></p>
<div style="text-align:center;">
<div><b>State</b>:<t t-esc="data['form']['state_id.name']"/></div>
<div><b>Localaty</b>:<t t-esc="data['form']['localaty_id.name']"/></div>
<div><b>From</b>: <t t-esc="data['form']['date_from']"/><b>To</b>: <t t-esc="data['form']['date_to']"/></div>
</div>
</tr>
it's give this error :
QWebException: "state_id.name" while evaluating
"data['form']['state_id.name']"
I cann't understand your problem but you can find an idea of QWEB from here:
1- http://learnopenerp.blogspot.com/2016/11/how-to-create-qweb-reports-in-openerp.html
2- http://learnopenerp.blogspot.com/2016/09/how-to-create-custom-reports-in-odoo.html
Hope this will helps you.