Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

xml rpc -php

By
aneesh ATEES Infomedia Pvt Ltd
on 5/17/16, 6:05 AM 468 views
  • Search

/**
 * $client = xml-rpc handler
 * $relation = name of the relation ex: res.partner
 * $attribute = name of the attribute ex:code
 * $operator = search term operator ex: ilike, =, !=
 * $key=search for
 */

function search($client,$relation,$attribute,$operator,$keys) {
     var $user = 'admin';
     var $password = 'admin';
     var $userId = -1;
     var $dbname = 'db_name';
     var $server_url = 'http://localhost:8069/xmlrpc/';

     $key = array(new xmlrpcval(array(new xmlrpcval($attribute , "string"),
              new xmlrpcval($operator,"string"),
              new xmlrpcval($keys,"string")),"array"),
        );

     if($userId<=0) {
     connect();
     }

     $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("search", "string"));
     $msg->addParam(new xmlrpcval($key, "array"));

     $resp = $client->send($msg);
     $val = $resp->value();
     $ids = $val->scalarval();

     return $ids;
}

In this fucntion what is the  " client = xml-rpc handler" here what is the xml rpc handler for serach method?i want to know what is xml rpc handler?

0
Krupesh Laiya
On 5/17/16, 6:35 AM

$url = <insert server URL>;

$db = <insert database name>;

$username = "admin";

$password = <insert password for your admin user (default: admin)>;

$common = ripcord::client("$url/xmlrpc/2/common");

$common->version();

{

"server_version": "8.0",

"server_version_info": [8, 0, 0, "final", 0],

"server_serie": "8.0",

"protocol_version": 1,

}

$models->execute_kw($db, $uid, $password, 'res.partner', 'search', array( array(array('is_company', '=', true), array('customer', '=', true))));

Calling methods

The second endpoint is xmlrpc/2/object, is used to call methods of odoo models via the execute_kw RPC function.Each call to execute_kw takes the following parameters:

the database to use, a string

the user id (retrieved through authenticate), an integer

the user's password, a string

the model name, a string

the method name, a string

an array/list of parameters passed by position

a mapping/dict of parameters to pass by keyword (optional)

List records

Records can be listed and filtered via search().search() takes a mandatory domain filter (possibly empty), and returns the database identifiers of all records matching the filter. To list customer companies for instance:

Pagination

By default a search will return the ids of all records matching the condition, which may be a huge number. offset and limit parameters are available to only retrieve a subset of all matched records.


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 5/17/16, 6:05 AM
Seen: 468 times
Last updated: 11/24/16, 1:05 AM