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

I want To download payslip report from this script. But It shows 500 internel Server Error? Help me to find right code for this?

By
Amit
on 5/20/16, 3:14 AM 165 views

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()

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: 5/20/16, 3:14 AM
Seen: 165 times
Last updated: 5/20/16, 3:31 AM