Community mailing list archives

community@mail.odoo.com

Print report from Server Action

by
Same Motion S.A.C, Carlos Rodriguez
- 11/23/2016 11:45:43
Hello,

I have the need to print a report using a server action.

This is my code:

datas = {'ids': context.get('active_ids', [])}
res = object.read(['price_list', 'qty1', 'qty2', 'qty3', 'qty4', 'qty5'])
res = res and res[0] or {}
res['price_list'] = res['price_list'][0]
datas['form'] = res
action = { 'type' : 'ir.actions.report.xml' , 'report_name' : 'product.report_pricelist' , 'data' : datas , }

The report I am tryng to print is the product.report_pricelist (QWeb), the server action is linked to a button in a form.

But I get the following error:

<type 'exceptions.KeyError'>: "form" while evaluating
"get_pricelist(data['form']['price_list'])": (<class 'openerp.exceptions.QWebException'>, QWebException(ValueError(u'<type \'exceptions.KeyError\'>: "form" while evaluating\n"get_pricelist(data[\'form\'][\'price_list\'])"',),), <traceback object at 0x7fa7471917e8>)

Any help would be appreciated.

Regards,