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.
  • <Recordset>.write(values) updates field values on the recordset. It returns nothing.
  • <Recordset>.unlink() deletes the records from the database. It returns nothing.

The values argument is a dictionary, mapping field names to values to write. The methods are decorated with @api.multi, except for the create() method, which is decorated with @api.model.

Changed in Odoo 12  The create() method now also allows to create records in batches. This is done by passing as argument a list of dictionary objects, instead of a single dictionary object. ...

Get Odoo 12 Development Essentials - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.