The decorators discussed in the previous section allow us to add certain features to our models, such as implementing validations and automatic computations.
We also have the basic methods provided by the ORM, used mainly to perform CRUD (create, read, update and delete) operations on our model data. To read data, the main methods provided are search()
and browse()
. We will discuss these in Chapter 7, Business logic - supporting business processes.
Now we will explore the write operations provided by the ORM, and how they can be extended to support custom logic.
The ORM provides three methods for the three basic write operations:
<Model>.create(values)
creates a new record on the model. Returns the created record.<Recordset>.write(values)
updates field values on the recordset. Returns nothing.<Recordset>.unlink()
deletes the records from the database. Returns nothing.
The values
argument is a dictionary, mapping field...