I am trying to create a qweb report that is not based on certain record of module, but I would create a dictionary of records
and pass them to qweb template. I've done this on RML reports but here 'data['form'] is not recognized of qweb template. Data is empty.
User starts a wizard from a menu, where he selects month and year. After that data is prepared as a dictionary and is passed to the report.
Wizard part:
datas = {
'ids': ids,
, 'model': 'report.environmental.oils.wizard',
'form': data
}
return {
'type': 'ir.actions.report.xml',
'report_name': 'mga_reports.report_environmental_oils',
data': datas, }
Report declaration:
<report
id="action_report_environmental_oils"
model="report.environmental.oils.wizard"
name="mga_reports.report_environmental_oils"
file="mga_reports.report_environmental_oils"
report_type="qweb-pdf"
menu="False"
string="Environmental oils report"/>
I am not sure what model should I use in report definition, because report is not based on one, data will be computed from several one. I have also created parser file and data argument that comes in is empty
@api.multidef render_html(self, data=None):
report_obj = self.env['report']
report = report_obj._get_report_from_name('mga_reports.report_environmental_oils')
docargs = {
'doc_ids': self._ids,
'doc_model': report.model,
'docs': self,
} return report_obj.render('mga_reports.report_environmental_oils', docargs)
When I use data in qweb template data is empty in a got error.
<p t-esc="data['form']['date_from']"/>
Could someone help me with that case. I'm kind of lost... :-(