Odoo Help


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.


Programatically Print a Report and Save it to disk on Server

Cyrus Waithaka
on 2/11/16, 6:03 PM 520 views

Hi people.

I am looking for a way to print a report, say a quotation and saving it to disk on the server. Anyone with an idea on how I can achieve this? 

The reason behind this is that we want to maintain pdf documents of all sales offers. 

I know I can programatically generate and add the report as an attachment, but again, how can I get that attachment from the file system.


Axel Mendoza

--Axel Mendoza--
| 6 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 2/26/16, 10:08 PM

You are asking about two things

1- How to print a report(and get the binary data perhaps?)

result = self.pool.get('report').get_pdf(cr, uid, [res_id], report_name, context=ctx)


  • res_id is the id of the object to use in the report related to the model of the report, 

  • report_name is the name of the report to print used to locate the report template

  • result is the binary data of the pdf report

2- How get an already saved Odoo report file

obj = self.pool.get(report.model).browse(cr, uid, rec_id)

filename = eval(report.attachment, {'object': obj, 'time': time})

alreadyindb = [('datas_fname', '=', filename),('res_model', '=', report.model),('res_id', '=', rec_id)]

attach_ids = self.pool.get('ir.attachment').search(cr, uid, alreadyindb)

if attach_ids:

pdf = self.pool.get('ir.attachment').browse(cr, uid, attach_ids[0]).datas

pdf = base64.decodestring(pdf)

where report is the record of the report located by name object and res_id the id of the object of the model of the report

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)


Asked: 2/11/16, 6:03 PM
Seen: 520 times
Last updated: 4/20/16, 8:59 PM