Odoo Help

0

how to call a rml report from button ?

By
Rachid
on 10/3/14, 6:36 AM 1,840 views

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

1

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)

 

Expected:} at the end of } !!

Rachid
on 10/3/14, 7:34 AM

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.

Emipro Technologies Pvt. Ltd.
on 10/3/14, 7:41 AM

in Odoo v8.0 doesn't work !

Rachid
on 10/3/14, 7:58 AM

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

Emipro Technologies Pvt. Ltd.
on 10/3/14, 8:05 AM

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

Rachid
on 10/3/14, 8:20 AM

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

Emipro Technologies Pvt. Ltd.
on 10/3/14, 10:29 AM

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)

Rachid
on 10/13/14, 7:00 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 10/3/14, 6:36 AM
Seen: 1840 times
Last updated: 3/16/15, 8:10 AM