콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
5103 화면

The Documentation, for both v15 and v16, shows the following prototype:

models.execute_kw(db, uid, password, 'res.partner', 'write', [[id], {'name': "Newer partner"}])

This is not quite enough information from which to generalize the structure of that final argument.  It's clear from the documentation that you can specify an array of id values and that will update all the associated records with the same data values.

However, what does the syntax look like if I am updating more than one field?

Is it this:   [[id], [{'field1name': "new field1 value"}, {'field2name'"new field2 value"} ] ]

Or this:   [[id], {'field1name'"new field1 value"'field2name'"new field2 value"} ]

Or something else again?

The documentation directs me to use the same structure as the create call, however, the create call has the same degenerate example for specifying the fields.

아바타
취소
작성자

I should mention that I am not using any of the example languages to generate these requests (Python, Ruby, etc.). I am building a .net application that will issue JSON requests to the API. For my purposes, it would be very useful to have the prototypes specified using simple JSON, rather than the execute_kw forms ... like this:
{ "jsonrpc": "2.0",
"method":"call",
"id":921359310,
"params": {
"service":"object",
"method":"execute_kw",
"args": [ "odoo_local", "2", "admin", "sale.order.line", "read", [[14, 15, 16, 17]] ]
}
}
These forms can be used, in Postman for example, to directly explore the API.

작성자 베스트 답변

So, via trial and error, I have discovered that this JSON works:

{
"service": "object",
"method": "execute_kw",
"args": [
"odoo_local",
2,
"admin",
"res.partner",
"write",
[ [21], { "website": "new website", "comment": "new comment" } ] ],
"context": {}
}

which is good to know, but a little unexpected.  It requires some gymnastics in a strongly typed language using json serialization of real objects.  Thanks to this GitHub repo for providing some clues.  It's kind of old, but uses an interesting style with dynamic objects to get over the hurdle.  Many thanks to that developer.

 https://github.com/GathSystemsOdoo/OdooRpc.CoreCLR.Client

My suggestion still stands about the JsonRpc documentation ... having plain old JSON objects, with enough examples to infer the structure, as well as the various language examples would be much appreciated.


아바타
취소
관련 게시물 답글 화면 활동
7
7월 25
18601
1
2월 25
1370
2
9월 24
1490
0
9월 24
802
1
5월 23
2520