Last active
June 18, 2020 19:12
-
-
Save yelizariev/9cfddc011e709c4740148a7793f6afc8 to your computer and use it in GitHub Desktop.
XMLRPC for apps.odoo.com
This file contains 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
// 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); }); | |
}); |
This file contains 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 | |
url = "http://apps.odoo.com" | |
db = "apps" | |
username = "[email protected]" | |
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': "[email protected]:odoo/odoo#10.0", | |
'vcs': "git", | |
'series_id': 13, | |
}]) |
This file contains 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
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); }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
xmlrpclib
works only for python2, for python3 you have to installxmlrpc
and importxmlrpc.client
instead (e.g.xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
.