43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
include_once("jsonrpc.php");
|
|
|
|
class ClassOdooJSONRPC {
|
|
public function __construct($url, $database, $user, $password){
|
|
$this->_url = $url;
|
|
$this->_database = $database;
|
|
$this->_user = $user;
|
|
$this->_password = $password;
|
|
|
|
$response = jsonrpc_request($this->_url."jsonrpc", "call", [
|
|
"service" => "common",
|
|
"method" => "login",
|
|
"args" => [$database, $user, $password]
|
|
]);
|
|
$this->_uid = $response["result"];
|
|
}
|
|
|
|
public function __destruct(){}
|
|
|
|
|
|
public function execute($model, $method, $args=[], $kwargs=[]){
|
|
return jsonrpc_request($this->_url."jsonrpc", "call", [
|
|
"service" => "object",
|
|
"method" => "execute_kw",
|
|
"args" => [
|
|
$this->_database,
|
|
$this->_uid,
|
|
$this->_password,
|
|
$model,
|
|
$method,
|
|
$args,
|
|
$kwargs
|
|
]
|
|
])["result"];
|
|
}
|
|
|
|
public function get_user_id(){
|
|
return $this->_uid;
|
|
}
|
|
}
|