Launch a report in a wizard based on osv.osv_memory

Asked by Jordi Esteve (www.zikzakmedia.com) on 2010-06-30

How a report could be launched at the end of the execution of a wizard based on osv.osv_memory (new wizards used in 5.0)?

For example, many of the old wizards generate a report defining in their workflow:

           'Result': ('type': 'print', 'report': 'account.account.balance', 'state': 'end')

I can not find how to do it with new wizards based on osv.osv_memory. I have look for examples in all official and extra addons modules and I have only found examples that closes the wizard:

    return {'type':'ir.actions.act_window_close' })

or opens a new tab in the client:

        return {
            'name': _("Sale Confirmation Emails"),
            'type': 'ir.actions.act_window',
            'res_model': 'travel_agency.createmail',
            'view_type': 'form',
            'view_mode': 'tree,form',
            'domain': "[('id', 'in', %s)]" % createmail_ids,
            'context': ctx,
        }

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
Adam James
Solved:
2010-07-01
Last query:
2010-07-01
Last reply:
2010-06-30
Best Adam James (adam-james) said : #1

Have a look at some of the account wizards in trunk. They use the following code:

return {
    'type': 'ir.actions.report.xml',
    'report_name': 'a.report.name',
    'datas': data,
}

`data' is a dictionary in the form of that passed to the wizard method as an argument.

Thank you, it works also in 5.0. But in 5.0 the 'datas' dictionary is useless: The information passed to the report throw the 'datas' field is lost.

In 5.0 the report called from the osv.osv_memory wizard receives:
  'ids' that contains the id of the wizard
  'data' dictionary that contains {'model': 'name_wizard_model'}
  'context' dictionary that contains for example {'lang': u'ca_ES', 'src_rec_id': 2, 'tz': False, 'src_model': 'res.partner', 'src_rec_ids': [2], 'active_ids': [2], 'template_id': '5', 'active_id': 2}

Luckily, with the first two, the information of the osv.osv_memory wizard can be recovered. And with the 'context' dictionary, the information of the original selected records before executing the wizard can be recovered (the ids are stored in 'active_ids').

Jordi

Niels Huylebroeck (red15) said : #3

Keep in mind the client is required to be 5.0.12 or higher.

See
http://bazaar.launchpad.net/~openerp/openobject-client-web/5.0/revision/2875
for the fix commited.

Jordi Esteve (www.zikzakmedia.com) wrote:
> Question #116262 on OpenObject Server changed:
> https://answers.launchpad.net/openobject-server/+question/116262
>
> Status: Answered => Solved
>
> Jordi Esteve (www.zikzakmedia.com) confirmed that the question is solved:
> Thank you, it works also in 5.0. But in 5.0 the 'datas' dictionary is
> useless: The information passed to the report throw the 'datas' field is
> lost.
>
> In 5.0 the report called from the osv.osv_memory wizard receives:
> 'ids' that contains the id of the wizard
> 'data' dictionary that contains {'model': 'name_wizard_model'}
> 'context' dictionary that contains for example {'lang': u'ca_ES', 'src_rec_id': 2, 'tz': False, 'src_model': 'res.partner', 'src_rec_ids': [2], 'active_ids': [2], 'template_id': '5', 'active_id': 2}
>
> Luckily, with the first two, the information of the osv.osv_memory
> wizard can be recovered. And with the 'context' dictionary, the
> information of the original selected records before executing the wizard
> can be recovered (the ids are stored in 'active_ids').
>
> Jordi
>
>