Skip to content

Instantly share code, notes, and snippets.

@gdalmau
Created November 15, 2018 11:54
Show Gist options
  • Save gdalmau/756b40cafd0291bb5498d13116e7dfa3 to your computer and use it in GitHub Desktop.
Save gdalmau/756b40cafd0291bb5498d13116e7dfa3 to your computer and use it in GitHub Desktop.
Imprimir report desde erppeek
import base64
import sys
import time
from subprocess import Popen
from erppeek import Client
c = Client(...
report = 'giscedata.facturacio.factura'
params = {'context': {}}
factura_ids = []
context = {
'lang': 'es_ES',
'tz': 'Europe/Madrid',
'active_id': factura_ids[0],
'active_ids': factura_ids,
}
report_id = c.report(report, factura_ids, params, context)
sys.stdout.write("Waiting")
res = {'state': False}
while not res['state']:
res = c.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']))
Popen(['okular', 'report.pdf'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment