好的,我正在尝试使用XML-RPC和PHP传递带有销售订单行的Odoo销售订单。 它工作得很完美......除非我无法传递product_id
所以这有效......
$lines[] = new xmlrpcval(
array(
new xmlrpcval(0, 'int'),
new xmlrpcval(0, 'int'),
new xmlrpcval(
array(
'name' => new xmlrpcval('Product Name', 'string'),
'product_uom_qty' => new xmlrpcval(5, 'int'),
'price_unit' => new xmlrpcval(10.00, 'double'),
'sub_total' => new xmlrpcval(50.00, 'double'),
),
"struct"
)
),
"array"
);
$arr = array(
'partner_id' => new xmlrpcval(236,"int"),
'partner_invoice_id' => new xmlrpcval(236,"int"),
'partner_shipping_id' => new xmlrpcval(236,"int"),
'client_order_ref' => new xmlrpcval($this->id,"int"),
'order_line' => new xmlrpcval($lines, "array"),
);
var_dump($arr);
$client = new xmlrpc_client($this->server."object");
$client->return_type = 'phpvals';
// ['execute','userid','password','module.name',{values....}]
$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($this->database, "string")); //* database name */
$msg->addParam(new xmlrpcval($this->uid, "int")); /* useid */
$msg->addParam(new xmlrpcval($this->password, "string"));/** password */
$msg->addParam(new xmlrpcval("sale.order", "string"));/** model name where operation will held * */
$msg->addParam(new xmlrpcval("create", "string"));/** method which u like to execute */
$msg->addParam(new xmlrpcval($arr, "struct"));/** parameters of the methods with values.... */
$resp = $client->send($msg);
if ($resp->faultCode()){
echo 'failed';
var_dump($resp);
return -1; /* if the record is not created */
}else{
echo 'success';
var_dump($resp);
return $resp->value(); /* return new generated id of record */
}
所以要正确附加产品(匹配openerp / odoo数据库中的产品)我需要传递产品ID ......
所以如果我在数组中添加以下行......
'product_id' => new xmlrpcval(38, 'int'),
然后我得到一个像以下那样的错误......
warning -- MissingError
One of the documents you are trying to access has been deleted, please try again after refreshing.
不确定我做错了什么,但这让我疯了! 我已经检查过产品ID 38了!
很多很多,非常感谢提前!!
答案 0 :(得分:1)
您的product_id错了。要确保将产品导出到csv,然后从设置中进行检查 - >外部标识符&序列。查看您的产品记录ID。
答案 1 :(得分:0)
将您的product_id
换入intval