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.


Trying to get a pdf with xmlrpc api gives 500 INTERNAL SERVER ERROR

Jacob Steringa
on 7/22/14, 6:33 AM 2,233 views

So I am trying to print an invoice with the xmlrpc api. I used the example from the api docs (https://doc.odoo.com/6.1/developer/12_api/#python-example) but it seems not to work.


import xmlrpclib
import time
import base64

u = '****'
pwd = '****'
db = '****'

sock_common = xmlrpclib.ServerProxy('http://*********:8069/xmlrpc/common')
uid = sock_common.login(db, u, pwd)

sock_print = xmlrpclib.ServerProxy('http://*********:8069/xmlrpc/report')
report_id = sock_print.report(db, uid, pwd, 'account.invoice', [1], {'model': 'account.invoice', 'id': 1, 'report_type': 'pdf'})


state = False
attempt = 0

while not state:
    report = sock_print.report_get(db, uid, pwd, report_id)
    state = report['state']
    if not state:
        attempt += 1
    if attempt > 200:
        print 'Abort, too long delay'

pdf_string = base64.decodestring(report['result'])
pdf_file = open('/tmp/file.pdf', 'w')


2014-07-22 10:25:08,644 21122 ERROR jacob openerp.service.report: Exception: Required report does not e
xist: None
Traceback (most recent call last):
  File "/home/odoo/openerp/service/report.py", line 93, in go
    result, format = openerp.report.render_report(cr, uid, ids, object, datas, context)
  File "/home/odoo/openerp/report/__init__.py", line 40, in render_report
    return registry['ir.actions.report.xml'].render_report(cr, uid, ids, name, data, context)
  File "/home/odoo/openerp/api.py", line 204, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/odoo/openerp/addons/base/ir/ir_actions.py", line 139, in render_report
    new_report = self._lookup_report(cr, name)
  File "/home/odoo/openerp/api.py", line 204, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/odoo/openerp/addons/base/ir/ir_actions.py", line 131, in _lookup_report
    raise Exception, "Required report does not exist: %s" % r
Exception: Required report does not exist: None

Does anyone know what the problem might be?


Ludo - Neobis

--Ludo - Neobis--
| 2 2 5
Hoogvliet, Netherlands
--Ludo - Neobis--


Ludo - Neobis
On 7/22/14, 8:09 AM

Well, the error tells you the report does not exist, so it is most likely looking for a report name that is not present in the database.

You are most likely using Odoo 8 or up (because I spotted the old_api in the stack trace) and when I search my own database, there is indeed no such report.

Try replacing the search line:

report_id = sock_print.report(db, uid, pwd, 'account.invoice', [1], {'model': 'account.invoice', 'id': 1, 'report_type': 'pdf'})
report_id = sock_print.report(db, uid, pwd, 'account.invoice', [1], {'model': 'account.invoice', 'id': 1, 'report_type': 'qweb-pdf'})


And see if that works. I can't check it for you now, so it is a guess.

Jacob Steringa
On 7/22/14, 8:51 AM

Thank you for your answers, it helped me understand the problem better. After fooling around with erppeek and studying the source code, i've come to the conclusion that the report for account.invoice does not exist. I used account.report_invoice instead and it works like a charm!

And indeed, the report_type should be qweb-pdf. The resulting call:

report_id = sock_print.report(db, uid, pwd, 'account.report_invoice', [1], {'model': 'account.report_invoice', 'id': 1, 'report_type': 'qweb-pdf'})

Thanks again :)

On 7/22/14, 8:08 AM

The trouble is the name of the report.

"Required report does not exist: NoneTraceback (most recent call last):"

MAy you can check your report name and path line by line with print... so some debuging process must in this case.


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

2 follower(s)


Asked: 7/22/14, 6:33 AM
Seen: 2233 times
Last updated: 3/16/15, 8:10 AM