On 10 Oct 23:15, Albert Cervera i Areny wrote: > 2014-10-10 9:21 GMT+02:00 <frederic.lange...@coopengo.com>: > > Hi devs, > > > > I m trying to call a tryton web service (for example create) via XML RPC > > from php but encountered somme issues. > > If someone already succeed in calling tryton from php, can you please > > provide an example? > > Please, try the following code (adapted to your config): > > equire_once 'jsonRPCClient.php'; > > $rpcClient = new jsonRPCClient('http://localhost:8000/database',true); > > $session = $rpcClient->cl('common.db.login',array('admin','admin')); > $context = > $rpcClient->cl('model.res.user.get_preferences',array($session[0],$session[1],true,array(1=>1))); > > $parties = > $rpcClient->cl('model.party.party.search_read',array($session[0],$session[1],array(),0,10,false,$context)); > > $addresses = > $rpcClient->cl('model.party.address.search_read',array($session[0],$session[1],array(array('party','=', > 1)),0,10,false,array(),$context)); > > $sale = > $rpcClient->cl('model.sale.sale.create',array($session[0],$session[1],array(array("party"=> > 1,"invoice_address"=> 1,"sale_date"=>'2014-02-15', > "lines"=>array(array("create", array( > > array("product"=>1,"description"=>"test","unit"=>1,"quantity"=>5,"unit_price"=>1.12), > > array("product"=>1,"description"=>"test","unit"=>1,"quantity"=>2,"unit_price"=>1.3) > ))) > )),$context)); > > > It was some code we did with a php developer some months ago just to > ensure it worked. Note that object IDs are hardcoded. > > Please, let me know if it works because we patched standard > jsonRPCClient.php but I'm not sure it was really necessary. If needed, > I can send it to you.
Could you also add it to https://code.google.com/p/tryton/wiki/RemoteCalls -- Cédric Krier - B2CK SPRL Email/Jabber: cedric.kr...@b2ck.com Tel: +32 472 54 46 59 Website: http://www.b2ck.com/
pgpOPzvV_kviz.pgp
Description: PGP signature