Community mailing list archives

community@mail.odoo.com

Re: About JSON-RPC in odoo

by
j.zahid
- 05/07/2015 07:46:43
Hi andré,
thank you a lot for your answer. I'll try that library. I also found this one http://gauravsahu.github.io/odoo-client-JSON-RPC/ wich uses also javascript.
Our apps are android native, so we need to connect to Odoo using android-jsonrpc.3.4 library.

best regards


SSLL, Intégrateur Odoo.
Intégration de Services.
BI and IT consulting.
j.zahid@auriumtechnologies.com
tél  0661360233 - 0636898882
fax 0528215738

On Wed, May 6, 2015 at 5:08 PM, André P. <app@thinkopen.solutions> wrote:
No docs as far as I know, but I've had success using this library: https://github.com/Textalk/jquery.jsonrpcclient.js

Here's a small example:

            login = new $.JsonRpcClient({ ajaxUrl: 'https://odoo.example.com/web/session/authenticate' });
            login.call('call', {"base_location": "https://odoo.example.com",
                                "db": "mydatabase",
                                "login": "admin",
                                "password": "admin",
                                "context": {}}, function(data) {
                                       client = new $.JsonRpcClient({ ajaxUrl: 'https://odoo.example.com/web/dataset/call_kw' });
                                       client.call('call', {"context": {},
                                                            "model": "res.partner",
                                                            "method": "create",
                                                            "args": [{"name": "John",
                                                                      "email": "john@example.com"}],
                                                            "kwargs": {"context": {}},
                                                            "session_id": data.session_id}, function(done) {
                                                                 console.log("Partner created");
                                                            });
                                       });
             });

This code logs in to the database, then creates a new res.partner and finally sends a message to the log confirming the creation.

Beware that if you need to run this code outside the same domain as the Odoo instance, you need to set up the CORS headers (https://en.wikipedia.org/wiki/Cross-origin_resource_sharing). We use Nginx as a reverse proxy to Odoo, so we configured it to add the headers on the replies.

2015-05-06 13:03 GMT+01:00 zahid jalal <j.zahid@gmail.com>:
Hi every one

We have devlopped many Odoo/openerp mobile/webapp clients using the XMLRPC webservice. Now we are trynig to rewrite some of them to use JSON-RPC . But we are confronted to the lack of documentation about JSON-RPC in odoo.
This page https://www.odoo.com/documentation/8.0/howtos/backend.html#webservices was not of a great help. it does not not provide any information about urls to use for different call requests, nor the way to use session trough many json call.

Is there any source of some extensive documentation abour JSON-RPC in Odoo ?

thanks

Jalal ZAHID

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe




--



André Paramés

e.  app@thinkopen.solutions

LISBOA

Avenida das Túlipas,

nº 6, 13º A/B 

1495-161 Algés

t.   +351 808 455 255

PORTUGAL | BRASIL | ANGOLA

PORTO

Rua do Espinheiro,

nº 641, 2 SALA 2.3 

4400-450 V.N. Gaia

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe