This question has been flagged

import xmlrpclib

import time

import base64

username = 'admin' # The Odoo user

pwd = '*******'# The password of the Odoo user

dbname = 'YesRegulatorySandBox' # The Odoo database

# OpenERP Common login Service proxy object

sock_common = xmlrpclib.ServerProxy ('http://localhost:8069/xmlrpc/common')

uid = sock_common.login(dbname, username, pwd)

sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/report')

report_id = sock.report(dbname, uid, pwd, 'hr.payslip', [1], {'model': 'hr.payslip', 'id': 1, 'report_type': 'qweb-pdf'})

time.sleep(3);

state = False

attempt = 0

while not state:

report = sock.report_get(dbname, uid, pwd, report_id)

state = report['state']

if not state:

time.sleep(1)

attempt += 1

if attempt > 200:

print 'Abort, too long delay'

pdf_string = base64.decodestring(report['result'])

pdf_file = open('/tmp/report/file.pdf', 'w')

pdf_file.write(pdf_string);

pdf_file.close()

Avatar
Discard