~carlos-realsystems/+junk/openacademy

« back to all changes in this revision

Viewing changes to openacademy/xml-rpc/test-report.py

  • Committer: Carlos Contreras
  • Author(s): carlos at com
  • Date: 2011-09-09 21:08:55 UTC
  • Revision ID: carlos@realsystems.com.mx-20110909210855-m0gds7nj5760jxul

[IMP] Implementacion de Wizard
Creamos el modelo del wizard herendado
de las clase osv.osv_memory.
uno que es el contenedor del wizard
y el otro que es el objeto contenido
Adicionalmente devolvemos en el wizard
una vista del elemento que se afecta.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
import time
 
3
import base64
 
4
import xmlrpclib
 
5
HOST='localhost'
 
6
PORT=8069
 
7
DB='security2'
 
8
USER='admin'
 
9
PASS='admin'
 
10
url ='http://%s:%d/xmlrpc/' % (HOST,PORT)
 
11
 
 
12
 
 
13
sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/common')
 
14
uid = sock.login(DB,USER,PASS)
 
15
sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object')
 
16
printsock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/report')
 
17
model = 'account.invoice'
 
18
ids = sock.execute(DB, uid, PASS, 'account.invoice', 'search', [('type', '=', 'out_invoice')])
 
19
id_report = printsock.report(DB, uid, PASS, model, ids, {'model': model, 'id': ids[0], 'report_type':'pdf'})
 
20
time.sleep(5)
 
21
state = False
 
22
attempt = 0
 
23
while not state:
 
24
    report = printsock.report_get(DB, uid, PASS, id_report)
 
25
    state = report['state']
 
26
    if not state:
 
27
        time.sleep(1)
 
28
        attempt += 1
 
29
    if attempt>200:
 
30
        print 'Printing aborted, too long delay !'
 
31
 
 
32
    string_pdf = base64.decodestring(report['result'])
 
33
    file_pdf = open('file.pdf','w')
 
34
    file_pdf.write(string_pdf)
 
35
    file_pdf.close()