December 2018
Beginner to intermediate
404 pages
10h 14m
English
We can also use the write() method to update several fields of several records at the same time, using a single database instruction. So its usage should be preferred in cases where efficiency is important.
The write() method takes a dictionary to map fields to values. These are updated on all elements of the recordset and nothing is returned, as shown here:
>>> recs = Partner.search( [('name', 'ilike', 'Azure')] )>>> recs.write({'comment': 'Hello!'})True
Unlike object-style assignment, when using the write() method, we can't assign recordset objects to relational fields directly. Instead, we need to use the record IDs that need to be extracted from the recordset.
When writing on a many-to-one field, the value ...
Read now
Unlock full access