Last active
January 30, 2023 06:57
-
-
Save ppa-odoo/9b033cbca47a8177e2f54384e321abf1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xmlrpclib | |
HOST = 'localhost' | |
PORT = 8069 | |
DB = 'DATABASE_NAME' | |
USER = 'admin' | |
PASS = 'admin' | |
ROOT = 'http://%s:%d/xmlrpc/' % (HOST,PORT) | |
# 1. Login | |
uid = xmlrpclib.ServerProxy(ROOT + 'common').login(DB,USER,PASS) | |
print "Logged in as %s (uid:%d)" % (USER,uid) | |
proxy = xmlrpclib.ServerProxy(ROOT + 'object') | |
# 2. Read the sessions | |
sessions = proxy.execute(DB, uid, PASS, 'MODEL_NAME','search_read', DOMAIN, FIELDS) | |
for session in sessions: | |
print "Session %s (%s seats)" % (session['name'], session['seats']) | |
# 3.create a new session | |
course_id = proxy.execute(DB, uid, PASS, 'MODEL_NAME', 'search', DOMAIN)[0] | |
print course_id | |
session_id = proxy.execute(DB, uid, PASS, 'MODEL_NAME', 'create', { | |
'name' : 'My session', #FIELD NAME | |
'course_id' : course_id, #FIELD NAME | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment