Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
5075 Visualizzazioni

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.

Avatar
Abbandona
Autore

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.

Autore Risposta migliore

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.


Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
7
lug 25
18497
1
feb 25
1357
2
set 24
1486
0
set 24
793
1
mag 23
2511