Thanks for your answer: following your example i finally understand how to create an empty dictionary and not an empty list : the trick is array(1=>1) Now it's working well
Le vendredi 10 octobre 2014 23:15:55 UTC+2, Albert Cervera i Areny a écrit : > > 2014-10-10 9:21 GMT+02:00 <frederic...@coopengo.com <javascript:>>: > > 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. > > -- > Albert Cervera i Areny > Tel. 93 553 18 03 > @albertnan > www.NaN-tic.com >