Skip to content

Instantly share code, notes, and snippets.

@yelizariev
Last active June 18, 2020 19:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yelizariev/9cfddc011e709c4740148a7793f6afc8 to your computer and use it in GitHub Desktop.
Save yelizariev/9cfddc011e709c4740148a7793f6afc8 to your computer and use it in GitHub Desktop.
XMLRPC for apps.odoo.com
// Step 1. Ask support team to set some temporar password on apps.odoo.com database
// Step 2. Login to https://apps.odoo.com/web in a usual way (via oauth)
// Step 3. Open browser console and change password by using js code below
odoo.define('www', function(require) {
"use strict";
var ajax = require('web.ajax');
// will only work after the password has been set by Odoo
ajax.jsonpRpc('/web/session/change_password', 'call', {
'fields' : [
{'name': 'old_pwd', 'value': 'demoo'},
{'name': 'new_password', 'value': 'demooo'},
{'name': 'confirm_pwd', 'value': 'demooo'}
]})
.then(function(o) { console.log(o); });
});
import xmlrpclib
url = "http://apps.odoo.com"
db = "apps"
username = "your-email@example.com"
password = "demooo"
common = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(url))
common.version()
uid = common.authenticate(db, username, password, {})
models = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url))
common = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(url))
common.version()
uid = common.authenticate(db, username, password, {})
if not uid:
print "Auth KO"
exit(0)
models = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url))
repos = models.execute_kw(
db, uid, password,
'loempia.series', 'search_read',
[[]],
dict(fields=['name'], limit=20)
)
import pprint; pprint.pprint(repos)
new_repo = models.execute_kw(db, uid, password, 'loempia.repo', 'create', [{
'url': "git@github.com:odoo/odoo#10.0",
'vcs': "git",
'series_id': 13,
}])
odoo.define('www', function(require) {
"use strict";
var ajax = require('web.ajax');
// will only work after the password has been set by Odoo
ajax.jsonpRpc('/web/dataset/search_read', 'call', {"model":"loempia.module.purchase","offset":0,"limit":80, "domain":[], "fields": ["module_maintainer_id", "order_name", "module_id", "state"]}).then(function(o) { console.log(o); });
});
@bitsnaps
Copy link

bitsnaps commented Jun 18, 2020

The xmlrpclib works only for python2, for python3 you have to install xmlrpc and import xmlrpc.client instead (e.g. xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment