Odoo Help


Programatically Print a Report and Save it to disk on Server

Cyrus Waithaka
on 2/11/16, 6:03 PM 1,961 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--
| 7 8 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 and 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

Blady Shaman
On 4/11/18, 12:40 PM

Anybody knows how to save it in a specific directory?

why would you want to do that if you can save it in the db with the fields.Binary? If you really want to you'll need to use python write https://www.programiz.com/python-programming/file-operation but you'll probably run into permission problems on the server and you'll have to get the path where to store from the server admin.

Samo Arko
on 4/12/18, 2:11 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.


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)


Asked: 2/11/16, 6:03 PM
Seen: 1961 times
Last updated: 4/11/18, 12:40 PM