forked from ctmil/tutorial_xmlrpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upd_quants.py
executable file
·31 lines (24 loc) · 1.05 KB
/
upd_quants.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/python
import sys
import xmlrpclib
import ssl
username = 'admin' #the user
pwd = 'demo_stock' #the user
dbname = 'demo_stock' #the database
gcontext = ssl._create_unverified_context()
# Get the uid
sock_common = xmlrpclib.ServerProxy ('http://demo_server:8069/xmlrpc/common',context=gcontext)
uid = sock_common.login(dbname, username, pwd)
#replace localhost with the address of the server
sock = xmlrpclib.ServerProxy('http://demo_server:8069/xmlrpc/object',context=gcontext)
location_id = sock.execute(dbname,uid,pwd,'stock.location','search',[('usage','=','internal')])
product_id = sock.execute(dbname,uid,pwd,'product.product','search',[('default_code','=','PROD_STOCK')])
quant_id = sock.execute(dbname,uid,pwd,'stock.quant','search',[('product_id','=',product_id[0]),('location_id','=',location_id[0])])
if quant_id:
quant_data = sock.execute(dbname,uid,pwd,'stock.quant','read',quant_id)
print quant_data
vals_update = {
'quantity': 555
}
return_id = sock.execute(dbname,uid,pwd,'stock.quant','write',quant_id,vals_update)
print return_id