I first started using Jasper Report for OpenERP 5. I used a wizard( created using wizard.interface) and the data provided in the wizard is passed to the Jasper Report module and that’s it. A well aligned attractive report is created in pdf, xls, html or txt format respective to the report type I provide in the wizard. This works well in openerp-client as well as openerp-web. Then I get a chance to create the Jasper Report in OpenERP v6. It was simple to change the same jasper report module of openerp5 to openerp6 and it works fine in openerp-client. But when I opened openrp- web and tried to create the report some unknown characters are printed in the html page and only the html report is working correctly. I spent hours in this issue and then Jabir, one of the hardcore programmer of zbeanz told me that openerp6 had stopped providing support to wizard.interface and told me to use the osv_memory to create the wizard. So I started creating Jasper Report using osv_memory.
When creating a wizard using osv.osv_memory we need to create a model and view for the wizard, the same process we use to create a model and view using osv.osv. The main difference inusing osv.osv and osv.osv_memory is that it osv_memory doesnt create tables in the database and osv_memory creates a table in the memory only when the wizard model is active.
If we are creating a multi-stage(multi-state) wizard then each stage depends on the value ‘state‘ defined in the field of the wizard model
For the state field we have to provide a default value. When we click on the wizard the view depends on this default state.We also have to define some functions that return a value to the next state or returns a value to the report. In my wizard there is only one stage in which when I click on the create button a report(Jasper report ) is created. The function is given below.
Here ‘report_name’ is the name of the report. This is the place where our jasper report is called. I’m providing the name of the jasper report that is already created myself. At the report module we get the ‘datas’ from the data. And data[‘form’] will give all the values provided in the wizard model. Here id and ids are not necessary. ‘nodestroy’ is for not destroying the wizard when creating the report.
VIEW PART
Define the record then define form. Inside the form define group for each state.
Inside this group define all the fields that should display in this stage. Then create buttons, one for cancelling the wizard and other for creating the report.
The object type button has the name create_report which is a function defined in the wizard model. After creating the report define the actions and also specify the jasper report file location. Create the menuitem where you want to display the wizard.
Our wizard creation is now complete and now restart our server and update our module, the new wizard will start working. We The ZbeanZ team are providing this module to the users who are interested in Jasper Report creation using osv_memory so that you people can check it out. I have attached the module with iths article. If there is any doubt feel free to contact us.
omalbastin: please check in a database with demo data.Empty pdf wil be generated if no data is passed to jasper. Values to the report should be passed from this generate_record() function as a list of dictionaries, ".
Leave a Reply