Odoo Help

Welcome!

This community 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.

0

Is there a way to store the content of a report in a variable?

By
Luis Masuelli
on 9/18/15, 1:17 PM 378 views

This is how I print a report:

    def yoursister(self, cr, uid, ids, context=None):
        """
        """
        return {
            'type': 'ir.actions.report.xml',
            'report_name': 'trescloud_ats_2013_report',
            'datas': {
                'model': 'sri.ats.2013',
            'res_ids': ids
        }
    }

Is there a way I can get this report's (it is an aeroo report) content as a string (e.g. a string suitable to be stored in a .binary field) instead of just downloading it?

0
Luis Masuelli
On 9/18/15, 5:09 PM

Found it :D.

Assuming your report has the Service Name "your.sister" (which is **not** necessarily the xml id, but the respective field), you can run the following code:

    obj = netsvc.LocalService('report.your.sister')
    (xml_content, format) = obj.create(cr, uid, [], datas, context)

Where:

  • The name in report_name (in the returned-dict way) is the name to be used as argument for LocalService, except that you **must** prefix it with "report.".

  • The dictionary passed as value for 'datas' key is the exact same it will be used in the 4th argument (the one which I conveniently named `datas`).

  • The returned value will be the file content and the file format.

its new idea to me... thanks bro

pks
on 9/19/15, 2:28 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 9/18/15, 1:17 PM
Seen: 378 times
Last updated: 9/18/15, 5:09 PM