How to pass multiple module data to a QWeb report? Is there something similar to passing dictionary in rendering html from controller?
Below is the code to create a custom Model report which is wrapped on v9 API. Creating custom object report is three step process
RML Prase Custom Report Object
import time
from openerp.osv import osv
from openerp.report import report_sxw
class CustomReportPrint(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(CustomReportPrint, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
'lst': self._lst,
'total': self._some_total,
'get_records':self._get_records,
})
def _get_records(self, res_ids):
records = self.pool.get('res.partner').browse(self.cr, self.uid, res_ids)
return records
def _lst(self, employee_id, dt_from, dt_to, max, *args):
#Your code goes here
return res
def _some_total(self, employee_id, dt_from, dt_to, max, *args):
#Your code goes here
return [result_dict]
Wrapping RML Prase Object tot he QWeb Engine.
class report_custom_print(osv.AbstractModel):
_name = 'report..report_custom_print'
_inherit = 'report.abstract_report'
_template = '.report_custom_print'
_wrapped_report_class = CustomReportPrint
Report XML look as below as you can see I am calling get_records
from custom report model.
Registering Report
Custom Print Report
qweb-pdf
res.partner
.report_custom_print
.report_custom_print
In custom Rml report Object you can define as many functions as you like and register them under __int__
and you can call those function directly on yor rpeort and mutpllate data as you need.
PS: replace with your module to make wit works correct.
Hope this will help.