Update List Records
Records can be updated using write(), it takes a list of records to update and a mapping of updated fields to values similar to create().
Multiple records can be updated simultaneously, but they will all get the same values for the fields being set. It is not currently possible to perform computed updates (where the value is set depending on an existing value of a record).
PUT /restapi/1.0/object/{object_name}?ids={comma_separated_ids}&vals={fields_and_values_to_update}
Request:
PUT /restapi/1.0/object/res.partner?ids=17,20&vals={'street2':'Chung Hsiao East Road'} HTTP/1.1
Host: {your_Odoo_server_url}
JSON Response:
HTTP/1.1 200 OK
{
'Partner': [
{
'id': 17,
'name': 'Edward Foster',
'street': '69 rue de Namur',
'street2': 'Chung Hsiao East Road',
'city': 'Wavre',
'state_id': false,
'zip': '1300',
'country_id': [274, 'Belgium'],
'create_date': '2017-07-04 18:10:31',
'create_uid': [1, 'Administrator'],
'write_date': '2017-07-13 11:18:28',
'write_uid': [1, 'Administrator'],
...
...
...
},
{
'id': 20,
'name': 'Peter Mitchell',
'street': '31 Hong Kong street',
'street2': 'Chung Hsiao East Road',
'city': 'Taipei',
'state_id': false,
'zip': '106',
'country_id': [482, 'Taiwan'],
'create_date': '2017-07-12 13:34:22',
'create_uid': [1, 'Administrator'],
'write_date': '2017-07-13 11:18:28',
'write_uid': [1, 'Administrator'],
...
...
...
}
]
}
XML Response:
HTTP/1.1 200 OK
<res.partner type="list">
<item type="dict">
<id type="int">17</id>
<name type="str">Edward Foster</name>
<street type="str">69 rue de Namur</street>
<street2 type="str">Chung Hsiao East Road</street2>
<city type="str">Wavre</city>
<state_id type="bool">false</state_id>
<zip type="str">1300</zip>
<country_id type="list">
<item type="int">274</item>
<item type="str">Belgium</item>
</country_id>
<create_date type="str">2017-07-10 11:02:57</create_date>
<create_uid type="list">
<item type="int">1</item>
<item type="str">Administrator</item>
</create_uid>
<write_date type="str">2017-07-10 15:02:57</write_date>
<write_uid type="list">
<item type="int">1</item>
<item type="str">Administrator</item>
</write_uid>
</item>
<item type="dict">
<id type="int">20</id>
<name type="str">Peter Mitchell</name>
<street type="str">31 Hong Kong street</street>
<street2 type="str">Chung Hsiao East Road</street2>
<city type="str">Taipei</city>
<state_id type="bool">false</state_id>
<zip type="str">106</zip>
<country_id type="list">
<item type="int">482</item>
<item type="str">Taiwan</item>
</country_id>
<create_date type="str">2017-07-12 13:34:22</create_date>
<create_uid type="list">
<item type="int">1</item>
<item type="str">Administrator</item>
</create_uid>
<write_date type="str">2017-07-12 13:34:22</write_date>
<write_uid type="list">
<item type="int">1</item>
<item type="str">Administrator</item>
</write_uid>
</item>
</res.partner>
Query Parameters:
vals –
fields to update and the value to set on them::
{'field_name': field_value, ...}
see write() for details.
Request Headers
Accept – the response content type depends on Accept header
Authorization – The OAuth protocol parameters to authenticate.
Response Headers
Content-Type – this depends on Accept header of the request
Status Codes
200 OK – no error
404 Not Found – there’s no resource
401 Unauthorized – authentication failed
403 Forbidden – if any error raise
Last updated