This question has been flagged
1 Reply
14743 Views

This question has been questioned before, since there is still no answer i need to ask again

 

return self.env['report'].get_action(self, 'my_module_my_template', data=datas)

I passed python dictionary in data. But it is None  when I print in Xml.

<t t-esc="data"/>

Can anyone explain how can I solve this ?

Avatar
Discard
Best Answer

Hi Jodi,

Hope you are using Odoo V10. You will not get the data in the XML directly as far as my knowledge is about.

You can  get the data in the XML/ report template , for that  what you have to do is,

Add a python file like this,

from odoo import models, api


class ReportClassName(models.AbstractModel):
_name = 'report.module_name.report_name'

@api.model
def render_html(self, docids, data=None):
print "data....", data
docargs = {
'doc_ids': self.ids,
'doc_model': self.model,
'data': data,
}
return self.env['report'].render('module_name.report_name', docargs)

Here in the python file, you will receive the data in the data. So from this render_html  function you have to append the data into docargs dictionary.

Then you can receive the data in the report template.

Now  print the data like this,

<t t-esc="data"/>

Thanks

Avatar
Discard
Author

Thanks for the fast and accurate reply. It works