OpenERP XML-RPC PHP insert into re.users with company_id


OpenERP XML-RPC PHP insert into re.users with company_id

我想用下面的代码插入res.users:

   $values= array(
        "name"=>new xmlrpcval($name,"string"),
        "login"=>new xmlrpcval($login,"string"),
        "password"=>new xmlrpcval($psw,"string"),
        "lang"=>new xmlrpcval("it_IT","string"),
        "company_id"= new xmlrpcval($company,"many2one");
    );
    echo $id= $this->create($values,"res.users");

我正在使用具有所有可能权限的用户。

函数返回-1状态,表示我没有权限或格式没有更正。

如果我删除company_id字段,它可以工作。

try this,

Many2one是创建记录的存储int id。所以在company_id中传递int的格式。

$values= array(
    "name"=>new xmlrpcval($name,"string"),
    "login"=>new xmlrpcval($login,"string"),
    "password"=>new xmlrpcval($psw,"string"),
    "lang"=>new xmlrpcval("it_IT","string"),
    "company_id"= new xmlrpcval($company,"int");
);
echo $id= $this->create($values,"res.users");