Using the ORM built-in methods
The model definition-related methods can do many things, but some business logic is not possible through them, so it needs to be attached to the ORM record writing operations.
ORM provides methods to perform Create, Read, Update, and Delete (CRUD) operations on our model data. Let's explore these write operations and how they can be extended to support custom logic.
To read data, the main methods that are provided are search()
and browse()
, as discussed in Chapter 7, Recordsets – Working with Model Data.
Methods for writing model data
The ORM provides three methods for the three basic write operations, shown as follows:
<Model>.create(values)
creates a new record on the model. It returns the created record.values
can be a dictionary or a list of dictionaries for mass-creating records.<Recordset>.write(values)
updates the recordset with thevalues
dictionary. It returns nothing.<Recordset>.unlink...