1
# -*- encoding: utf-8 -*-
2
# List field and first 5 element of table in argv
3
import xmlrpclib,ConfigParser,sys
5
# Set up parameters (for connection to Open ERP Database) ********************************************
6
# Set up parameters (for connection to Open ERP Database) ********************************************
7
config = ConfigParser.ConfigParser()
8
config.read(['openerp.cfg']) # if file is in home dir add also: , os.path.expanduser('~/.openerp.cfg')])
9
dbname=config.get('dbaccess','dbname')
10
user=config.get('dbaccess','user')
11
pwd=config.get('dbaccess','pwd')
12
server=config.get('dbaccess','server')
13
port=config.get('dbaccess','port') # verify if it's necessary: getint
15
# For final user: Do not modify nothing below this line (Python Code) ********************************
16
sock = xmlrpclib.ServerProxy('http://' + server + ':' + port + '/xmlrpc/common')
17
uid = sock.login(dbname ,user ,pwd)
18
sock = xmlrpclib.ServerProxy('http://' + server + ':' + port + '/xmlrpc/object')
22
tabella_id = sock.execute(dbname, uid, pwd, tabella, 'search', [])
23
tabella_campi=sock.execute(dbname,uid,pwd,tabella,'read',tabella_id)
24
tot={'partner':0, 'customer':0, 'supplier':0, 'both': 0, 'address': 0, 'address_extra': 0}
26
for elemento in tabella_campi:
28
if elemento['customer']:
30
if elemento['supplier']:
32
if elemento['supplier'] and elemento['customer']:
34
if elemento['address']:
35
tot['address'] += len(elemento['address'])
36
tot['address_extra'] += tot['address'] - tot['partner']
38
print "Totale: \t%s" % (tot['partner'],)
39
print "Customer: \t%s" % (tot['customer'],)
40
print "Supplier: \t%s" % (tot['supplier'],)
41
print "C + S: \t%s" % (tot['both'],)
42
print "Address: \t%s" % (tot['address'],)
43
print "Address extra:\t%s" % (tot['address_extra'],)