Working with the server
Our server code will usually run inside a method of a model, as is the case for do_mass_update()
in the preceding code.
In this context, self
represents the recordset being acted upon. Instances of model classes are actually recordsets. For actions executed from views, this will be only the record currently selected on it. If it's a form view, it is usually a single record, but in tree views, there can be several records.
The self.env
object allows us to access our running environment; this includes the information on the current session, such as the current user and session context, and also access all the other models available in the server.
To better explore programming on the server side, we can use the server interactive console, where we have an environment similar to what we can find inside a model method.
This is a new feature for version 9. It has been back-ported as a module for version 8, and it can be downloaded from the link https://www.odoo.com/apps/modules...