Skip to content

Instantly share code, notes, and snippets.

@ecarreras
Forked from tinogis/report.py
Last active August 29, 2015 14:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ecarreras/e350f8fd52b4a341228f to your computer and use it in GitHub Desktop.
Get and view an erp5 pdf report from command line
from erppeek import Client
import sys
import base64
from subprocess import call
import time
report = 'xml_report_name'
ids = [object_id]
O = Client('http://localhost:8069', 'database','user','pass')
report_id = O.report(report, ids)
sys.stdout.write("Waiting")
res = {'state': False}
while not res['state']:
res = O.report_get(report_id)
sys.stdout.write(".")
time.sleep(0.2)
sys.stdout.flush()
sys.stdout.write("\n")
with open('report.pdf','w') as f:
f.write(base64.b64decode(res['result']))
call(['evince', 'report.pdf'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment