Beispiel #1
1
 public function Logon($username, $domain, $password)
 {
     $common = ripcord::client(ODOO_SERVER . '/xmlrpc/2/common');
     $this->uid = $common->authenticate(ODOO_DB, $username, $password, []);
     $this->username = $username;
     $this->domain = $domain;
     $this->password = $password;
     if ($this->uid) {
         $this->models = ripcord::client(ODOO_SERVER . '/xmlrpc/2/object');
         $this->models->_throwExceptions = true;
         $partners = $this->models->execute_kw(ODOO_DB, $this->uid, $password, 'res.users', 'search_read', [[['id', '=', $this->uid]]], ['fields' => ['partner_id']]);
         if (count($partners) == 0) {
             return false;
         }
         ZLog::Write(LOGLEVEL_DEBUG, 'Odoo::Logon: $partners = (' . print_r($partners, true)) . ')';
         $this->partnerID = $partners[0]['partner_id'][0];
         ZLOG::Write(LOGLEVEL_INFO, 'Odoo:Logon: Logged in with partner/user id ' . $this->partnerID . '/' . $this->uid);
         # timezone
         $users = $this->models->execute_kw(ODOO_DB, $this->uid, $password, 'res.users', 'search_read', [[['id', '=', $this->uid]]], ['fields' => ['tz']]);
         $user = $users[0];
         $this->utz = $user['tz'];
         return true;
     }
     return false;
 }
Beispiel #2
0
 public static function client($url, $options = null)
 {
     try {
         return new ar_connect_xmlrpcClient(ripcord::client($url, $options));
     } catch (Ripcord_Exception $e) {
         return new ar_error($e->getMessage(), $e->getCode());
     }
 }
 /**
  *调用方法
  */
 function calling_methods($post_param, $model = "eshop.to.odoo")
 {
     $uid = $this->logging_in();
     $models = ripcord::client("{$this->url}/xmlrpc/2/object");
     file_put_contents('api_juzhen.log', date("Y-m-d H:i:s", time()) . ' $post_param:' . print_r($post_param, 1) . "\r\n", FILE_APPEND);
     $re = $models->execute_kw($this->db, $uid, $this->password, $model, 'synchronous_method', array(json_encode($post_param), array()));
     file_put_contents('api_juzhen.log', date("Y-m-d H:i:s", time()) . ' $re:' . print_r($re, 1) . "\r\n", FILE_APPEND);
     return $re;
 }
Beispiel #4
0
 public function CreatePO($docHeader, $docDetailAr)
 {
     $models = ripcord::client("{$this->url}/xmlrpc/2/object");
     $id = $models->execute_kw($this->db, $this->uid, $this->password, 'res.partner', 'create', [['name' => "New Partner"]]);
     return $id;
     //        $search_id = $models->execute_kw($db, $uid, $password,
     //            'product.product', 'search', array(
     //                array(array('default_code', '=', '7wonder'))));
     //        var_dump($search_id);
     //        return;
     //
     //        $result = $models->execute_kw($db, $uid, $password,
     //            'product.template', 'search_read',
     //            array(array(array('active', '=', true))),
     //            array('fields'=>array('name', 'list_price'), 'limit'=>5));
     //        var_dump($result);
     //
     //
     //        $name = "New Product2";
     //        $product_template_id = $models->execute_kw($db, $uid, $password,
     //            'product.template', 'create',
     //            array(array('name'=>$name)));
 }
Beispiel #5
0
 public function __construct()
 {
     $this->odoo_url = C('odoo_config.basic.odoo_url');
     $this->odoo_db = C('odoo_config.basic.odoo_db');
     $this->odoo_username = C('odoo_config.basic.odoo_username');
     $this->odoo_password = C('odoo_config.basic.odoo_password');
     require_once APPPATH . 'third_party/ripcord-1.1/ripcord.php';
     $this->common = ripcord::client("{$this->odoo_url}/xmlrpc/2/common");
     $this->uid = $this->common->authenticate($this->odoo_db, $this->odoo_username, $this->odoo_password, array());
     $this->models = ripcord::client("{$this->odoo_url}/xmlrpc/2/object");
 }