Using 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 commands to see how they work. This 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 12-library
You should see the usual server start up sequence in the terminal until it stops on a >>>
Python prompt waiting for your input.
Note
Changed in Odoo 9
The shell feature was added in version 9.0. For version 8.0, there is a community back-ported module to add it. Once downloaded and included in the addons path, no further installation is necessary. It can be downloaded from https://www.odoo.com/apps/modules/8.0/shell/.
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
'OdooBot'
>>>...