Skip to Content
Menu
This question has been flagged
2 Replies
4196 Views

How can I do ths kind of report in QWEB? All the selected payments should be in one page only. Is there a way to do this?


PAGE 1

Transaction Date
Check Date
Bank
Check #

Customret

02/12/16
02/18/16
Bank1
0123
Cust1
02/16/16
02/29/16
Bank2
4561

Cust2

02/18/16
02/25/16
Bank3
7548Cust3

Avatar
Discard
Best Answer

Hi Samantha

Your error is due to this line:

'get_data': self._get_data(voucher), 

because you are getting the result of the _get_data method call and assign it to the localcontext dict. Change it to:

'get_data': self._get_data, 

And you will be ok. The localcontext is were you put some info available to the report and for function calls in the report you need to use the function object reference

Avatar
Discard
Author Best Answer

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)

Avatar
Discard

i have the same error have you found any solution ??

Related Posts Replies Views Activity
4
Nov 24
5235
1
Mar 24
395
3
Sep 23
22647
0
Feb 24
1718
1
Oct 22
2786