由于OpenERP / Odoo的xml-rpc文档很差,有人可以给出如何在PHP中创建sale.order的答案吗?
答案 0 :(得分:0)
以下是创建新订单的方法,另一种是创建订单行的方法
function createNewOrder($params,$model_name)
{
$client = new xmlrpc_client($this->server . "object");
$client->return_type = 'phpvals';
$msg = new xmlrpcmsg('execute');
$nval = array();
foreach($params as $k=>$v){
$nval[$k] = new xmlrpcval( $v, xmlrpc_get_type($v) );
}
$msg->addParam(new xmlrpcval($this->database, "string")); //* database name */
$msg->addParam(new xmlrpcval($this->uid, "int"));
$msg->addParam(new xmlrpcval($this->password, "string"));
$msg->addParam(new xmlrpcval($model_name, "string"));
$msg->addParam(new xmlrpcval("create", "string"));
$msg->addParam(new xmlrpcval($nval, "struct"));
//$msg->addParam(new xmlrpcval($orderPrd, "struct"));
$resp = $client->send($msg);
//$order_id_line[] = $this->$resp->value()->scalarval();
if ($resp->errno != 0)
trigger_error("sock_execute error " . $resp->errstr);
return $resp->value();
}
function createOrderLine($params,$model_name){
$client = new xmlrpc_client($this->server . "object");
$client->return_type = 'phpvals';
$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($this->database, "string")); //* database name */
$msg->addParam(new xmlrpcval($this->uid, "int"));
$msg->addParam(new xmlrpcval($this->password, "string"));
$msg->addParam(new xmlrpcval($model_name,"string"));
$msg->addParam(new xmlrpcval("create", "string"));
$msg->addParam(new xmlrpcval($params, "struct"));
$res = $client->send($msg);
return $res;
}