我的 PHP 脚本可能如下所示:
function neworder($uid,$pwd,$objname,$methname,$params){
$client = new xmlrpc_client("/xmlrpc/object", "localhost", 8069);
$message = new xmlrpcmsg('execute');
$message->addparam(xmlrpc_encode($uid));
$message->addparam(xmlrpc_encode($pwd));
$message->addparam(xmlrpc_encode($objname));
$message->addparam(xmlrpc_encode($methname));
$message->addparam(xmlrpc_encode($params));
$resp = $client->send($message);
if ($resp->errno!=0) trigger_error ("sock_execute error ".$resp->errstr);
return xmlrpc_decode($resp->value());
}
$uid = 1;
$pwd = 'password';
$order = array(
'name'=> 'order22',
'shop_id'=> 1,
'state'=> 'draft',
'user_id'=> 4,
'partner_id'=> 7,
'partner_invoice_id'=> 1,
'partner_order_id'=> 1
);
$order_id = neworder($uid, $pwd, 'sale.order', 'create', $order);
echo("a new order ".$order_id." is added");
我正在使用 Ubuntu 和 OpenERP 7。当我运行脚本时出现错误。