Odoo Help

0

Batch Report using Report Parser?

By
Samantha Cruz
on 3/7/16, 2:22 AM 846 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

1
Axel Mendoza
On 3/9/16, 2:47 AM

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

0
Samantha Cruz
On 3/7/16, 7:58 PM

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)

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

Alaa Ahmed
on 6/3/17, 5:43 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 3/7/16, 2:22 AM
Seen: 846 times
Last updated: 3/9/16, 2:47 AM