Php 调用  RPC 在 odoo 创建订单


Php 调用 RPC 在 odoo 创建订单

www.chinamaker.net 2016-04-12 08:49:06 admin

最近一客户需要在自己的电商中台中同步订单,下面把接口分享出来。

1)创建订单
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();
    }

2)创建订单行
    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;
    }




 

来源:苏州远鼎官网


相关标签 TAG :  Php  调用    RPC  odoo  创建订单  


苏州远鼎

运用前沿科学技术,苏州远鼎信息技术有限公司以开源管理软件产品为核心,为企业和政府组织提供软件及服务,是OpenERP(Odoo)专业服务商,中国开源管理软件服务市场的领跑者。

Read More

远鼎产品

联系远鼎

  • 苏州工业园区星湖街328号22栋301
  • +86-0512-69361217
  • odoo@chinamaker.net
  • www.chinamaker.net