This question has been flagged
1 Reply
4319 Views

I have a report created in rml and I want to call it from a button nor than print option

Avatar
Discard
Best Answer

Hello,

you can return the following values on the click of button. It will print the report.

        return {
            'type': 'ir.actions.report.xml',
            'report_name': '<name.of.your.report>',
            'datas':< { data : which you want to use in the report } >,
        }

You can find this kind of ex. in the account module.

In odoo V8 you can use as like below.

    def _print_report(self, cr, uid, ids, data, context=None):
        if context is None:
            context = {}
        data['form'].update(self.read(cr, uid, ids, ['initial_balance', 'amount_currency'])[0])
        return self.pool['report'].get_action(cr, uid, [], 'account.report_partnerledger', data=data, context=context)

 

Avatar
Discard
Author

Expected:} at the end of } !!

Just have a look on the following it is simple example into account module. def _print_report(self, cr, uid, ids, data, context=None): if context is None: context = {} data['form'].update(self.read(cr, uid, ids, ['display_partner'])[0]) return { 'type': 'ir.actions.report.xml', 'report_name': 'account.partner.balance', 'datas': data, } It is working well.

Author

in Odoo v8.0 doesn't work !

I have update my answer please have a look. Thanks.

Author

I get this error: SyntaxError: JSON.parse: unexpected end of data at line 2 column 1 of the JSON data http://localhost:9090/web/js/web.assets_backend/33b98d6:2890

can you put your entire code in the Q ? It is easy to fix it.

Author

voilà=== def print_rml(self, cr, uid, ids, data, context=None): if context is None: context = {} return self.pool['report'].get_action(cr, uid, [], 'sale_comarev.report_rml', context=context)