0

I'm trying to insert in res.users with this code:

   $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");

I'm using a user with all the possible privileges.

The function returns a -1 state that means that I've no permission or the format is not corrected.

It works if I remove the company_id field.

the
  • 21,007
  • 11
  • 68
  • 101
Vanojx1
  • 5,574
  • 2
  • 23
  • 37
  • I've no experience of openerp, but you could do some basic troubleshooting by either (1) using the user account you are working with, trying an insert that is known to work. (2) trying the insert with a user account that is known to work. Unless there is another issue, that should help narrow things down a bit. – Raad Jun 19 '14 at 13:16

1 Answers1

1

try this,

Many2one is store int id of record created. So in company_id pass int in format.

$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");
Bhavesh Odedra
  • 10,990
  • 12
  • 33
  • 58