Working with the ORM API
From the previous section, we already got a taste of what it is like to use the ORM API. Next we will look at what more we can do with it.
The shell command
Python has a command-line interface that is a great way to explore its syntax. Similarly, Odoo also has an equivalent feature, where we can interactively try out commands to see how they work. That is the shell
command.
To use it, run Odoo with the shell
command and the database to be used, as shown here:
$ ./odoo-bin shell -d todo
You should see the usual server start up sequence in the terminal until it stops on a >>>
Python prompt waiting for your input. Here, self
will represent the record for the Administrator
user, as you can confirm by typing the following:
>>> self
res.users(1,)
>>> self._name
'res.users'
>>> self.name
'Administrator'
In the shell session here, we inspected our environment. The self
represents a res.users
recordset containing only the record with the ID 1
...