I can't edit my question.
This is my code (as of now) but it returns an error:
QWebException: ""'account.voucher.pay.detail' object is not callable" while evaluating
'get_data(o)'" while evaluating
report_parser.py
from openerp import models
from openerp.report import report_sxw
class report_parser(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(pdc_report_parser, self).__init__(cr, uid, name, context=context)
active_ids = context.get('active_ids')
account_voucher = self.pool.get('account.voucher')
docs = account_voucher.browse(cr, uid, active_ids, context)
voucher = []
for voucher_id in active_ids:
voucher_id = account_voucher.browse(cr, uid, voucher_id, context)
voucher.append(voucher_id)
self.localcontext.update({
'docs': docs,
'get_data': self._get_data(voucher),
'hello_world': self._hello,
})
def _hello(self):
return "Hello World!"
#It returns all ids of the object 'account.voucher.pay.detail' based on voucher_ids that was selected
def _get_data(self, voucher_id):
print "voucher_id:", voucher_id
pay_details = []
account_voucher_pay_detail = self.pool['account.voucher.pay.detail']
for rec in voucher_id:
details = account_voucher_pay_detail.search(self.cr, self.uid,
[('voucher_id', '=', rec.id)])
if details:
pay_details = pay_details + details
pay_details = account_voucher_pay_detail.browse(self.cr, self.uid, pay_details)
return pay_details
class pdc_report_parser_test(models.AbstractModel):
_name = 'report.parser_module.report_test_document'
_inherit = 'report.abstract_report'
_template = 'parser_module.report_test_document'
_wrapped_report_class = report_parser
report_test_document.xml
<?xml version="1.0" encoding="utf-8"?>
<!--Custom report.-->
<openerp>
<data>
<template id="report_test_doc">
<t t-call="module_parser.my_layout">
<div class="page">
<table class="table table-condensed">
<thead>
<tr>
<th>Transaction Date</th>
<th>Check Date</th>
<th>Bank/Branch</th>
<th>Check No.</th>
<th>Amount</th>
<t t-if="o.partner_id.customer">
<th>Customer</th>
</t>
<t t-if="o.partner_id.supplier">
<th>Supplier</th>
</t>
</tr>
</thead>
<tr t-foreach="get_data(o)" t-as="pd">
<td>
<span t-field="o.date"/>
</td>
<td>
<span t-field="pd.date_due"/>
</td>
<td>
<span t-field="pd.name"/>
</td>
<td>
<span t-field="pd.check_no"/>
</td>
<td>
<span t-field="pd.amount"/>
</td>
<td>
<span t-field="o.partner_id.name"/>
</td>
</tr>
</table>
</div>
</t>
</template>
<template id="report_test_document">
<t t-call="report.html_container">
<t t-foreach="doc_ids" t-as="doc_id">
<t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'module_parser.report_test_doc')"/>
</t>
</t>
</template>
</data>
</openerp>
In the default, it can print all necessary information but per page (1 voucher, 1 page) not in one page only (all vouchers selected in one page)