Get values from method in Odoo 8 API

a 夏天 提交于 2019-12-10 16:24:34

问题


I'm trying to interact with Odoo 8 API and get a list of fields. The method is called by ripcord XMLRPC library and this is the sentence:

$models = ripcord::client($url.'/xmlrpc/2/object');
        $models->execute_kw($dbname, $username, $password,'res.partner', 'fields_get', array(), array('attributes' => array('string', 'help', 'type')));

But I don't know how to get the response values...


回答1:


I have found the Some of the useful document which is related with the ODOO Web Service API in different languages Like Python,PHP, Ruby And Java ,

Please Click On Below Link Which is helpful for your solution.

ODOO Web Service API Reference

I hope this should helpful for you ..:)




回答2:


I have made my comments , kindly request you to find it as below it may help in your case.

Regarding: I don't know how to get the response values.

In ODOO ,We usually call the fields_get to get information about list of field associated with a specific model .

Let say i want to get the list of all the field present in res.partner.

ODOO have fields_get for retrieving all fields for a model .

require_once('ripcord-master/ripcord.php');

$url = "http://localhost:8059";           //ODOO  Server Url
$db ="ripcord_test_db";                   //Database Name
$username = "prakasharmacs24@gmail.com";  //UserName 
$password = "7959884833";                 //Password
$common = ripcord::client("$url/xmlrpc/2/common");

//Authenticate the credentials
$uid = $common->authenticate($db, $username, $password, array());
echo $uid;  //1

//Create Model Instance 
$models = ripcord::client("$url/xmlrpc/2/object");

// Fetch the data by calling appropriate methods
$partner_field = array();
$partner_field=$models->execute_kw($db, $uid, $password,
                           'res.partner', 'fields_get',array(),
                            array('attributes' => array('string', 'help', 'type')));

//print_r($partner_field);

Now you have all field in key-value array. But these record are to much expressive ,because you have type print_r($partner_field);

Now you have a array , just used it as per your requirement .

Lets say i am interested in field and it's type.

Here is code snippet for this :

function getfieldtype($field){

    return $field['type'];
}
print_r(array_map("getfieldtype",$partner_field));

I hope this may help you in finding the answer of your query .



来源:https://stackoverflow.com/questions/29602740/get-values-from-method-in-odoo-8-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!