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

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.

Awatar
Odrzuć
Autor

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.

Autor Najlepsza odpowiedź

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.


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
7
lip 25
17599
1
lut 25
1230
2
wrz 24
1399
0
wrz 24
720
1
maj 23
2429