1

I would like to transfer dataset from main report to subreport in iReport. In Odoo version7, I have used just like this.

<parameter name="param_obj" class="java.lang.Object" isForPrompting="false"/>
<subreport>
   <reportElement x="0" y="0" width="555" height="13"/><subreportParameter name="tl_cAsset">
     <subreportParameterExpression><![CDATA[$P{tl_cAsset}]]>  </subreportParameterExpression>
   </subreportParameter>
   <dataSourceExpression><![CDATA[$P{param_obj}]]></dataSourceExpression>
   <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "acc_balance_current_assets2.jasper"]]></subreportExpression>
</subreport>

Now I using Odoo version 8 and new jasper_reports module for version 8. So I transferred some of the jar files from jasper_reports module to iReport IDE. Later... all the reports from odoo version7 caused Groovy errors. That's why I changed Groovy language to Java language in iReport. But... all the subreports didn't work because param_obj paramter didn't bring the dataset to subreport.

If I changed dataSourceExpression from param_obj to $P{REPORT_DATA_SOURCE} that built-in parameter like this:

<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>

, I got the error like this:

Failed to invoke method execute in class com.nantic.jasperreports.JasperServer: Field "Name-name" not found in data source. 

subreport didn't get fields from the paramter datasource.

How should it be? I don't know how to pass the main dataset to subreport. If you don't mind, please explain step by step.

PS. I used XPath query language and used xml template file for that dataset.

Alex K
  • 22,315
  • 19
  • 108
  • 236
Sharifah
  • 361
  • 2
  • 17
  • 30
  • possible duplicate of [How to pass main report data source to subreport (JasperReports)?](http://stackoverflow.com/questions/8490563/how-to-pass-main-report-data-source-to-subreport-jasperreports) – GenericJon Feb 11 '15 at 15:02

1 Answers1

0

Use field tag instead of parameter tag.

It means, you can replace :

<parameter name="param_obj" class="java.lang.Object" isForPrompting="false"/>

With:

<field name="param_obj" class="java.lang.Object" />

If it is not ok, you can try with another way in here.

Community
  • 1
  • 1
Ye Win
  • 2,020
  • 14
  • 21
  • If I changed like this, I got this error : Failed to invoke method execute in class com.nantic.jasperreports.JasperServer: com.nantic.jasperreports.LanguageTable cannot be cast to net.sf.jasperreports.engine.JRDataSource – Sharifah Feb 11 '15 at 09:33
  • I had 7 subreports for this. I called each subreport as shown on above. I've already tested that link. Thanks for your help! – Sharifah Feb 11 '15 at 10:00
  • Ohh I see.When change field tag, JRDataSource error is occured, it's wired because field tag is okay in my testing project.But i use JRBeanCollectionDataSource in my code. – Ye Win Feb 11 '15 at 10:09
  • I also didn't get with JRBeanCollectionDataSource. What's wrong with this???? :'( – Sharifah Feb 11 '15 at 10:22
  • could you please provide your server side(java) code.? – Ye Win Feb 13 '15 at 05:04
  • I have been customizing Odoo version 8 module for report by using python language. I think.. it's because of version 8 jasper_reports module or iReport .. In version 7, it's okay for all subreports. In version 8, I changed iReport Groovy language to Java language.. Is it the main problem for these subreports? – Sharifah Feb 18 '15 at 07:21