Creating a Jasper Report using osv_memory in OpenERP

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.

Comments

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

Your email address will not be published. Required fields are marked *

  1. Anonymous says:

     hei budd.. i need ur help.. i have install this module.. but error like this "  File "/home/adsoft/OpenObject/addons-openerp-indonesia/jasper_reports/jasper_report.py", line 232, in __init__

        if name in netsvc.SERVICES:
    AttributeError: ‘module’ object has no attribute ‘SERVICES’  "
     
     im installed on openerpv6.02… thanks b4
    1. Dinil UD says:

      Infact that module is not work indipendent. Actually the intelligence behind the working of that module is modified version of ‘jasper_report’ module by NAN.

      Dinil UD <dinilud@gmail.com>

       

    2. anoop@zbeanztech.com says:

       HI

      please use this jasper report

      http://dl.dropbox.com/u/12447821/jasper_reports.zip

  2. nadhiya says:

    hi
    i write a wizard,the wizard thus not invoke the report.when am clicking the report button the window will close.”it shows
    (, KeyError(‘report.anabond_sale_report’,), )
    but am having that report in correct location.

  3. Anonymous says:

    Hi Omal
    Thanks for the great example.
    I have installed your module on OpenERP 6.0.2, but the option to change the format of the report from ‘pdf’ to ‘xls’ or ‘html’ does not work – the report is always a ‘pdf’
    Is this something you tested on your system and it worked?
    Thanks

  4. Anonymous says:

    Sir, Can you please explain about how to configure jasper report with openerp

  5. walid says:

    Hello,
    I installed the “Jasper Report using osv_memory” in OpenERP 6 all went without error but it returned me empty pdf
    help me please

    1. omalbastin says:

      Please check the data you are passing to jasper reports. Take a look at the data you are returning from gererate_records() function from your report parser.

      1. walid says:

        Please, I’m a beginner, I did not understand

        1. omalbastin says:

          In the module, goto report/report_user_analysis.py, there you can find a function called generate_records(). Please check the value it return

          1. walid says:

            returns nothing

          2. omalbastin says:

            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,

  6. walid says:

    Hello,
    I’m starting with openerp 6
    I want to create a form with two fields (start_date and end_date) and print button
    I want when I click the print button, I get a pdf repport that contains the list of users that are added between the two dates
    Help me please

  7. walid says:

    Hello,
    I’m starting with openerp 6 I want to create a form with two fields (start_date and end_date) and print button I want when I click the print button, I get a pdf repport that contains the list of users that are added between the two dates
    Help me please

© 2020 Zesty Beanz Pvt Ltd All Rights Reserved.