odoo,通过xml-rpc访问并且正确

时间:2014-10-25 14:53:37

标签: php web-services xml-rpc odoo

昨天,我努力为我的电子商务软件开发xmlrpc。遵循odoo一般错误,我重新安装odoo。

我什么都没碰,我现在有这个错误而且我是管理员。 也许我忘记了某些事情或者在odoo代码中有一个小小的改变????

感谢

致命错误:在第173行的/home/www/clicshopping_test_ui/boutique/ClicCpanel/ext/odoo_xmlrpc/xml_rpc_admin_customers.php中调用非对象的成员函数scalarval()

print_r($response) do that :

object(xmlrpcresp)[36]
public 'val' => int 0
public 'valtyp' => null
public 'errno' => int -1
public 'errstr' => string '' (length=0)
public 'payload' => null
public 'hdrs' => 
array (size=4)
'content-type' => string 'text/xml' (length=8)
'content-length' => string '446' (length=3)
'server' => string 'Werkzeug/0.9.6 Python/2.7.8' (length=27)
'date' => string 'Sat, 25 Oct 2014 14:45:31 GMT' (length=29)
public '_cookies' => 
array (size=0)
empty
public 'content_type' => string 'text/xml' (length=8)
public 'raw_data' => string 'HTTP/1.0 200 OK
Content-Type: text/xml
Content-Length: 446
Server: Werkzeug/0.9.6 Python/2.7.8
Date: Sat, 25 Oct 2014 14:45:31 GMT

<?xml version='1.0'?>

的faultcode 警告 - AccessError

由于安全限制,无法完成请求的操作。请联系您的系统管理员。

(文件类型:res.partner,操作:阅读)

faultString

我的xml-rpc

// **********************************
// search iso code ClicShopping
// **********************************

$QcountryIdCustomer = $OSCOM_PDO->prepare("select entry_country_id
                                           from :table_address_book
                                           where customers_id = :customers_id
                                          ");
$QcountryIdCustomer->bindInt(':customers_id', (int)$customers_id );
$QcountryIdCustomer->execute();

$country_id_customer = $QcountryIdCustomer->fetch();
$country_id_customer = $country_id_customer['entry_country_id'];


$QcountryCode = $OSCOM_PDO->prepare("select countries_iso_code_2
                                     from :table_countries
                                     where countries_id = :countries_id
                                    ");
$QcountryCode->bindInt(':countries_id',(int)$entry_country_id);
$QcountryCode->execute();

$country_code = $QcountryCode->fetch();
$country_code = $country_code['countries_iso_code_2'];
// **********************************
// search id country odoo
// **********************************

$domain_filter = array (
  new xmlrpcval(
    array(
      new xmlrpcval('code' , "string"),
      new xmlrpcval('=',"string"),
      new xmlrpcval($country_code,"string"),
    ),"array"
  ),
);

$client = new xmlrpc_client($server_url . "/xmlrpc/object");
$client->setSSLVerifyPeer(0);

$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($dbname, "string"));
$msg->addParam(new xmlrpcval($uid, "int"));
$msg->addParam(new xmlrpcval($password, "string"));

$msg->addParam(new xmlrpcval("res.country", "string"));

$msg->addParam(new xmlrpcval("search", "string"));
$msg->addParam(new xmlrpcval($domain_filter, "array"));
$response = $client->send($msg);

if ($response->faultCode()){
  echo $response->faultString();
}

$result = $response->value();

$ids = $result->scalarval();

$id_list = array();
/*
for($i = 0; $i < count($ids); $i++){
$id_list[]= new xmlrpcval($ids[$i]->me['int'], 'int');
}
*/
$id_list[]= new xmlrpcval($ids[0]->me['int'], 'int');

$field_list = array(new xmlrpcval("country_id", "int"),
                    new xmlrpcval("name", "string"),
);

$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($dbname, "string"));
$msg->addParam(new xmlrpcval($uid, "int"));
$msg->addParam(new xmlrpcval($password, "string"));
$msg->addParam(new xmlrpcval("res.country", "string"));
$msg->addParam(new xmlrpcval("read", "string"));
$msg->addParam(new xmlrpcval($id_list, "array"));
$msg->addParam(new xmlrpcval($field_list, "array"));

$resp = $client->send($msg);

$result = $resp->value()->scalarval();
/*
for($i = 0; $i < count($result); $i++){
$country_id_odoo = ($result[$i]->me['struct']['id']->me['int']);
}
*/
$country_id_odoo = $result[0]->me['struct']['id']->me['int'];

// **********************************
// Search odoo customer id
// **********************************

$domain_filter = array (
  new xmlrpcval(
    array(
      new xmlrpcval('ref' , "string"),
      new xmlrpcval('=',"string"),
      new xmlrpcval('WebStore - ' . $customers_id,"string"),
    ),"array"
  ),
);

$client = new xmlrpc_client($server_url . "/xmlrpc/object");
$client->setSSLVerifyPeer(0);

$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($dbname, "string"));
$msg->addParam(new xmlrpcval($uid, "int"));
$msg->addParam(new xmlrpcval($password, "string"));
$msg->addParam(new xmlrpcval("res.partner", "string"));
$msg->addParam(new xmlrpcval("search", "string"));
$msg->addParam(new xmlrpcval($domain_filter, "array"));
$response = $client->send($msg);

$result = $response->value();
$ids = $result->scalarval();

$id_list = array();
/*
for($i = 0; $i < count($ids); $i++){
$id_list[]= new xmlrpcval($ids[$i]->me['int'], 'int');
}
*/
$id_list[]= new xmlrpcval($ids[0]->me['int'], 'int');

$field_list = array(new xmlrpcval("ref", "string"),
                    new xmlrpcval("id", "int"),
                  );

$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($dbname, "string"));
$msg->addParam(new xmlrpcval($uid, "int"));
$msg->addParam(new xmlrpcval($password, "string"));
$msg->addParam(new xmlrpcval("res.partner", "string"));
$msg->addParam(new xmlrpcval("read", "string"));
$msg->addParam(new xmlrpcval($id_list, "array"));
$msg->addParam(new xmlrpcval($field_list, "array"));

$response = $client->send($msg);

if ($response->faultCode()){
  echo $response->faultString();
}
line 170
$result = $response->value()->scalarval();

0 个答案:

没有答案