Creating and passing parameters from wizard to Aeroo report

Asked by Damián Soriano

I would like to create a wizard that collects some data from the user and based on it creates an Aeroo report.

1) Is it possible to create an Aeroo report from a wizard?
2) Is it possible to pass information from the wizard to the report parser?

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Addons (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
Damián Soriano
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
Lorenzo Battistini (elbati) said :
#1

Yes, take a look at this module http://apps.openerp.com/addon/6888

Revision history for this message
Damián Soriano (damiansoriano) said :
#2

Lorenzo, thanks for the reply. I took a look at the module and they pass some information from wizard to parser using 'datas' in the return of the calling function, I don't understand very well how you access that data later. The code of the wizard of the module is:

def print_invoice(self, cr, uid, ids, context=None):
    if context is None:
        context = {}
    datas = {'ids': context.get('active_ids', [])}
    datas['model'] = 'account.invoice'
    datas['form'] = self.read(cr, uid, ids)[0]
    return {
        'type': 'ir.actions.report.xml',
        'report_name': 'fattura_accompagnatoria',
        'datas': datas,
    }

I found more easy to use the context to pass information from wizard to Parser. Here is a draft of what I am doing and is working:

# The Wizard
class wizard(osv.osv_memory):
   def generate_report(self, cr, uid, ids, context=None):
        context['text'] = 'this was set in wizard'
        result = {'type' : 'ir.actions.report.xml',
                        'context' : context,
                        'report_name': 'report_name'}
        return result
wizard()

# The Parser
class Parser(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context):
        super(Parser, self).__init__(cr, uid, name, context)
        self.text_var = context['text']
        self.localcontext.update({'text': self.text_fun})

    def text_fun(self):
        return self.text_var

# In the .odt file we just use (as input field)
<caca_func()>

Lorenzo, what do you think about both solutions?

Revision history for this message
Lorenzo Battistini (elbati) said :
#3

Using context is certainly a valid solution

Revision history for this message
Damián Soriano (damiansoriano) said :
#4

Just one more question regarding this topic:

This solution works fine in the web client but does not work in the GTK client. Does anyone have any idea how to make it work in both clients?

Revision history for this message
Launchpad Janitor (janitor) said :
#5

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Damián Soriano (damiansoriano) said :
#6

All in all the question is answered, just the GTK client have the problem.

Revision history for this message
Damián Soriano (damiansoriano) said :
#7

All in all the question is answered, just the GTK client have the problem.

Revision history for this message
Nicola Riolini - Micronaet (nicolariolini) said :
#8

@damiansoriano
I see also difference in context with GTK and web, if you pass datas from wizard is better, remember that in ODT you can use object: data (without 's' ) to get datas value
so in wizard: datas['text']="Hi"
in ODT placeholder: data['text']

HTH

Revision history for this message
James Monod (james-monod) said :
#9

hello elbati,

When i go to your provided link http://apps.openerp.com/addon/6888 i got internal error.

Would you please provide latest link.

Thanks in advance

Revision history for this message
Serpent Consulting Services (serpent-consulting-services) said :
#10

James,

What is the error text?

Aeroo reports work fine.

Thanks.

Revision history for this message
Serpent Consulting Services (serpent-consulting-services) said :
#11

Try modules as from http://v6apps.openerp.com/?filter={%22order_by%22%3A+%22click_counter+desc%22%2C+%22text_search%22%3A+%22aeroo%22}&page=1

Try http://apps.openerp.com/addon/6887

Thanks.

Revision history for this message
James Monod (james-monod) said :
#12

Hello Serpent,

I downloaded the module product_catalog_aeroo_report from apps.openerp.com.

I have tried the module product_catalog_aeroo_report when i click on wizard button 'generate' it not generate report.

Thanks for your help

Revision history for this message
Serpent Consulting Services (serpent-consulting-services) said :
#13

James,

What error does it show? Did you see any traceback?

Report does not work, does not mean an issue with aeroo at all!

Thanks.