Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I pass values to the context of qweb reports that will be accessed on the template

Tags:

odoo

odoo-9

I have two values start_date and end_date that I want to access in the qweb template. How can I these values in the qweb.?

I am generating and then sending it to email. Here's how I am creating a report.

job_id = self.pool.get('module.report_name').search(self.env.cr, self.env.uid, [('date', '>=', start),('date', '<=', end)], context=None)
data, format = openerp.report.render_report(self.env.cr,self.env.uid, job_id, report.report_name, {}, {})
like image 820
Sharjeel Ali Shaukat Avatar asked Mar 17 '16 11:03

Sharjeel Ali Shaukat


1 Answers

While rendering report, the last argument is for passing the context to the reports. Pass your variables like that,

data, format = openerp.report.render_report(self.env.cr,self.env.uid, job_id, report.report_name, {}, {'start_date': start_date, 'end_date': end_date})

and then in qweb access them as,

<t t-esc="docs._context['start_date']"></t>
like image 56
Hammad Qureshi Avatar answered Sep 27 '22 18:09

Hammad Qureshi