Jasper Erpnext Integration

Thanks Fernandes. I tried to display the Cherry report(thats one of the examples) onload of user.js by calling the following functions:

jasper.getListOnly(“testName”, “User”);
jasper.getOrphanReport({jr_name: “Cherry Local”, jr_format: “pdf”, page: “testName”, doctype_type:“Form or List”, doctype:“User”, docids:[“krithi.ramani@gmail.com”, “Administrator”]});

But i get this error in my console:

Uncaught TypeError: Cannot read property ‘locale’ of undefined.

This happens when I set the locale to ‘India’ or ‘Ask’. robj in the following code seems to be undefined.

jasper.check_for_ask_param=function(rname,page,callback){
var robj=jasper.get_jasperdoc_from_name(rname,page);
var ret;
if(robj.locale===“Ask”||(robj.params&&robj.params.length>0)){
ret=jasper.make_dialog(robj,rname+" parameters",callback);}
else{
callback({abort:false});}};

The report however gets listed in the top right corner without any error.
Any clues??

TIA

Hi, thanks for your feedback.

you have an error in doctype_type filed of jasper.getOrphanReport. You must choose Form or List and not both. Try with Form:

jasper.getOrphanReport({jr_name: "Cherry Local", jr_format: "pdf", page: "testName", doctype_type:"Form", doctype:"User", docids:["krithi.ramani@gmail.com", "Administrator"]});

Thanks. But I still get the same error!!!

The error is because jasper don’t find your report.

Do you have Cherry Local report? In the image you provide you only have try_COA, try_Labels and try_ROA.

Still if you have Cherry Local report it must be associated to User doctype in my case is.

Try your try_COA report.
In my case here is the definition of Cherry Local report:

Hi,
I wanted to check the report generation from button click with one of the example reports. I had created Cherry based on your instructions in config.txt. It wasn’t there initially, I created it later. I am also able to generate it from the top right corner in User page…attached are the screenshots

Uploading Screenshot from 2015-10-03 05^%28^%49.png…

Uploading Screenshot from 2015-10-03 05^%39^%55.png…

Hi. It is very strange because i can generate my Cherry Local report that way.

Also, i can’t see your uploaded images.

Please, after command jasper.getListOnly("testName", "User") check if jasper.pages has Cherry local:

testName: {Custom Cherry Local 2: Object, Cherry Local: Object, Custom Cherry Local: Object, size: 3}

Please try the example from browser console. To see if the problem is in your user.js.

Sorry, it was my mistake. Just update jasper and everything is fix now… i hope!

It was a naive mistake!

now, put in your user.js this:

var list_reports = jasper.getListOnly("testName", "User");
list_reports.done(function(){
	jasper.getOrphanReport({jr_name: "Cherry Local", jr_format: "pdf", page: "testName", doctype_type:"Form", doctype:"User", docids:["luisfmfernandes@gmail.com", "Administrator"]});
});

Let me know.

Thanks.

Thanks a bunch, works like a charm. I need your help in few other things:

  1. How do I upload the jrxml files that has subreports? I get “Remove first the file (None) associated with this document or (None) is a wrong parent.” irrespective of the order I upload the files(parent first and then subreport or vice versa).

  2. One of my jrxml is not getting compiled and .jasper file is not created on uploading to Jasper Report. However the jrxml gets compiled without any problems in the Jasper studio. Is there a way I can track the issue?..The console just throws

Caused By:java.io.FileNotFoundException : /site1.local/jasper/try_Labels/compiled/Labels.jasper

  1. If I allow the report to ‘Ask’ for locale at runtime, I have no issues and the report gets downloaded easily.However, if I select the Locale as ‘India’ while creating a Jasper Report, I get the following error in the js console:

"Uncaught TypeError: Cannot read property ‘try_COA’ of undefined "

I sure would like to avoid this prompt at runtime. How should I do it?

Your quick response is much appreciated. thanks again.

Hi. Thanks for your support, i appreciate you to let me know of any error.

I will see if anything is wrong, but meanwhile i need to check if you are doing things write.

To answer to your 1. question, tell me: Are you putting one report inside another, like this:

The error you get is because you are putting another report and you already has one. You have to put the 2º report inside the first report, as a child in the tree structure.

For the last question. If you see my last image, i upload /Custom Cherry Local 2/compiled/localizationdemo.properties. My Jasper module does not check if localization.properties is uploaded because you can put that in java environment variable and has one general file. So, if you has localization and don’t provide you will get some errors.

Let me know if this help.

Am able to add .jpg and localizaationdemo.properties to the reports without any problems and it works fine. They dont get attached as a child though. see attachment:

near the upload button only the jrxml gets listed as an attached file.

However in my case, the report I have designed in Jasper studio has a subreport, which is another jrxml. May be because the files that I attach don’t go as a child, am not able to attach 2 .jrxml files.

Also, if I upload the parent report first and save, it throws error that the subreport is missing.

I hope I have made myself clear.

Regards

Hi.

Near the upload button you can click to see the tree structure.

Also to upload childs you have first to click in parent, in this case, click in /Cherry/Cherry.jrxml and then in upload button to upload as a child.

Keep me updated!

Yes, I see the tree in Cherry. But, with my subreport file, am not able to add the child even if I click on parent and then click upload. I get the same error…“Remove first the file (None) associated with this document or (None) is a wrong parent.”…Am i missing anything else?

krithi

Hi.

I fix the code. Now you can add a second report if it is a subreport.

The code will check if the subreport is indeed a subreport of the first one, so you must install first the parent.

Let me know if it is ok now.

Thanks.

Thanks much. I could now attach subreports without any error.

I need more clarification on setting the locale. It is not a parameter in my .jrxml file. It is set only when I create a Jasper Report in Erpnext. Kindly clarify why it wouldn’t accept a value I select in Jasper Report but works fine when I allow it to ‘Ask’ at runtime.

I replied too soon. Though it lets me upload the subreport, at run time, it gives JRException: Resource not found at :compiled/childlabel.jasper(see attached image)

If I run a report with the child alone, there are no issues though.

Hi.

To answer to localization question; you need to have one localization file for every language you want to support in your report. The name of the file need to be like this: anyname_es.properties or anyname_ca_ES.properties - this is for spain.
You can upload to jasper folder or you can put in your java classpath. Of course if you have many translation the preferred way is in classpath.

In the case of subreport error:

I need to know if the file exists childlabel.jasper in the compiled folder.

If exists then update jasper.

I appreciate any feedback.
Thanks.

Hi,
Yes, childlabel.jasper is present. Now, In jasper_reports.py, line 147, in getSubReportsQuery,

report_path = path_name.split("/",1 )[1][:-6] + "jrxml" 

I get “IndexError: list index out of range” error. I fixed it to [0][:-6]. The report gets generated without any issues now. Please test the same.

Thank you. I will let you know about the localization.

Hi.

I Fixed this and another error associated with this. Please update.

If you find more errors please tell me.

Thanks for help me to improve jasper.