Skip to Content
Menu
This question has been flagged
1 Reply
3261 Views

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
Discard
Author

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.

Author Best Answer

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
Discard
Related Posts Replies Views Activity
2
Sep 24
171
0
Sep 24
104
6
Aug 24
5737
1
May 23
1226
0
Jan 23
999