This forum is now just an archive. Use the new Q&A website
It is currently Sun Apr 20, 2014 6:50 pm

All times are UTC + 2 hours




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Xml Rpc
PostPosted: Wed Mar 21, 2012 12:07 pm 
Offline

Joined: Wed Sep 14, 2011 6:34 am
Posts: 21
Location: India
I wrote this PHP code for updating open erp db
<?php
include("xmlrpc.inc");
$userId=connect();
echo $userId;
write($userId);
function connect() {
$user = 'admin';
$password = 'vms';
$dbname = 'VmSoftwares';
$server_url = 'http://localhost:8069/xmlrpc/';
if(isset($_COOKIE["user_id"]) == true) {
if($_COOKIE["user_id"]>0) {
return $_COOKIE["user_id"];
}
}

$sock = new xmlrpc_client($server_url.'common');
$msg = new xmlrpcmsg('login');
$msg->addParam(new xmlrpcval($dbname, "string"));
$msg->addParam(new xmlrpcval($user, "string"));
$msg->addParam(new xmlrpcval($password, "string"));
$resp = $sock->send($msg);
$val = $resp->value();
$id = $val->scalarval();
setcookie("user_id",$id,time()+3600);
if($id > 0) {
return $id;
}else{
return -1;
}
}
function write($userId) {
$user = 'admin';
$password = 'vms';
$dbname = 'VmSoftwares';
$server_url = 'http://localhost:8069/xmlrpc/';
$relation='notebook';
$operator='=';
$client=new xmlrpc_client("http://localhost:8069/xmlrpc/object");
$attribute='title';
$ids='ss';
$key = array(new xmlrpcval(array(new xmlrpcval($attribute , "string"),
new xmlrpcval($operator,"string"),
new xmlrpcval($ids,"string")),"array"),
);
$data=array('note'=>new xmlrpcval('Fabien Pinckaers', "string"));


$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($dbname, "string"));
$msg->addParam(new xmlrpcval($userId, "int"));
$msg->addParam(new xmlrpcval($password, "string"));
$msg->addParam(new xmlrpcval($relation, "string"));
$msg->addParam(new xmlrpcval("write", "string"));
$msg->addParam(new xmlrpcval($key, "array"));
$msg->addParam(new xmlrpcval($data, "struct"));

$resp = $client->send($msg);
if ($resp->faultCode())

echo 'Error: '.$resp->faultString();

else
{
$val = $resp->value();
$record = $val->scalarval();

return $record;
}
}

?>
but i got this error
Error: Traceback (most recent call last): File "C:\Program Files\OpenERP 6.1-1\server\.\openerp\wsgi\core.py", line 79, in xmlrpc_return File "C:\Program Files\OpenERP 6.1-1\server\.\openerp\netsvc.py", line 360, in dispatch_rpc File "C:\Program Files\OpenERP 6.1-1\server\.\openerp\service\web_services.py", line 572, in dispatch File "C:\Program Files\OpenERP 6.1-1\server\.\openerp\osv\osv.py", line 121, in wrapper File "C:\Program Files\OpenERP 6.1-1\server\.\openerp\osv\osv.py", line 176, in execute File "C:\Program Files\OpenERP 6.1-1\server\.\openerp\osv\osv.py", line 164, in execute_cr File "C:\Program Files\OpenERP 6.1-1\server\.\openerp\osv\orm.py", line 3890, in write File "C:\Program Files\OpenERP 6.1-1\server\.\openerp\sql_db.py", line 244, in split_for_in_conditions TypeError: unhashable type: 'list'
pls help me to solve this.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC + 2 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:

Protected by Anti-Spam ACP