Last active
October 5, 2022 16:21
-
-
Save randall-vx/737cf3913225f10af4dfe0381aa74dd6 to your computer and use it in GitHub Desktop.
odoo appscript
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
url = <insert server URL> | |
db = <insert database name> | |
username = <insert username> | |
password = <insert password> | |
// Authenticate user and get uid: | |
var common = new XMLRPC.XmlRpcRequest(url + "/xmlrpc/2/common", "authenticate"); | |
common.addParam(db); | |
common.addParam(username); | |
common.addParam(password); | |
common.addParam({}); | |
uid = common.send().parseXML(); | |
// Check access right | |
var models = new XMLRPC.XmlRpcRequest(url + "/xmlrpc/2/object", "execute_kw"); | |
models.addParam(db); | |
models.addParam(uid); | |
models.addParam(password); | |
models.addParam('res.partner'); | |
models.addParam('check_access_rights'); | |
models.addParam(['read']); | |
models.addParam({'raise_exception': False}); | |
var response = models.send().parseXML(); | |
// create user | |
var models = new XMLRPC.XmlRpcRequest(url + "/xmlrpc/2/object", "execute_kw"); | |
models.addParam(db); | |
models.addParam(uid); | |
models.addParam(password); | |
models.addParam('res.partner'); | |
models.addParam('create'); | |
models.addParam([{ | |
'name': "New Partner", | |
}]); | |
id = models.send().parseXML(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment