Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
6 Odpowiedzi
45543 Widoki

Hello,

I'm trying to update a product but I can't find the correct JSON structure to do it. Here is what I've tried:

{
    "jsonrpc": "2.0",
    "method": "call",
    "params": {
        "model": "product.product",
        "ids": [
            77
        ],
        "vals": {
            "name_template": "Coca-Cola 50cl OK"
        },
        "context": {},
        "session_id": "f48b00a031fc4920af0b3e4ec04d9497"
    },
    "id": "r6"
}

on this URL: /web/dataset/write

All my "search_read" requests are working normaly but I need your help for the "write" one.

Could you help me?

-- Edit ----------

When I enabled the debug-rpc log level I can see that:

2014-04-28 19:58:13,507 7104 INFO ? werkzeug: 127.0.0.1 - - [28/Apr/2014 19:58:13] "POST /web/dataset/write HTTP/1.1" 404 -

The URL for write data seems to be false... Does someone knows it ?

-- Edit ----------

I've tried to edit my product through OpenERP web interface to see the log...

2014-04-28 20:26:50,864 7104 DEBUG database openerp.netsvc.rpc.request: object.execute_kw time:0.373s mem: 49368k -> 49452k (diff: 84k)(u'database', 1, '*', u'product.product', 'write', (...), {...})
2014-04-28 20:26:51,012 7104 INFO database werkzeug: 127.0.0.1 - - [28/Apr/2014 20:26:51] "POST /web/dataset/call_kw HTTP/1.1" 200 -

It seems send the request at /web/dataset/call_kw so when I send my request to this URL I receive this answer:

2014-04-28 20:52:41,036 7104 ERROR database openerp.addons.web.http.JSONRequest.dispatch: An error occured while handling a json request
Traceback (most recent call last):
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\web\http.py", line 204, in dispatch
TypeError: call_kw() got an unexpected keyword argument 'vals'
2014-04-28 20:52:41,184 7104 INFO database werkzeug: 127.0.0.1 - - [28/Apr/2014 20:52:41] "POST /web/dataset/call_kw HTTP/1.1" 200 -

An idea to solve my problem ?

Thanks.

Awatar
Odrzuć

Same problem..... Do you get any solution????

Same problem..... Do you get any solution????

hii i solve this prob... You are passing wrong string follow this link http://gauravsahu.github.io/odoo-client-JSON-RPC/

Najlepsza odpowiedź

hii

i solved this prob...

You are passing wrong string

follow this link
http://gauravsahu.github.io/odoo-client-JSON-RPC/

Awatar
Odrzuć

Is there any way to convert this to google script code?

Najlepsza odpowiedź

Hi,

The params for /web/dataset/call_kw are incorrect. They should be (model, methods, args, kwargs).
I have made it work using angular-odoo, though this is not required. Here you can find how "call" should be implemented on RPC.

Angular Odoo. Inspect the following js for further information:
https://github.com/akretion/angular-odoo/blob/master/dist/odoo.js#L5

Params you need (data):

{
\"jsonrpc\":\"2.0\",
\"method\":\"call\",
\"params\":{
    \"model\":\"product.product\",
    \"method\":\"write\",
    \"args\":[[20],{\"name\":\"Best Product Evaaa\"}],
    \"kwargs\":{\"context\":{}}
    }
}

Example (angular-odoo):

jsonRpc.call(    
    "product.product",
    "write",
    [[20], {'name': "Best Product Evaaa"}]
).then(function(res){
     console.log(res); // true
}, function(err){
     console.log(err);
)
Awatar
Odrzuć
Najlepsza odpowiedź

You have to use the url for all your requests, follow the examples of Gaurav Sahu.

http://%s:%s/jsonrpc

In this file you will find more answers of possible calls: Odoo 8.0 (on Ubuntu 14.04) /usr/lib/python2.7/dist-packages/openerp/http.py

 

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
mar 25
900
1
kwi 18
3508
0
paź 24
189
3
maj 21
7584
1
lis 20
10184