Using the shell command
Python includes a command-line interface that is a great way to explore the language. Odoo includes a similar feature through the shell
command option. These commands can be executed interactively to better understand how they work.
To use it, add the shell
command when starting Odoo, plus any Odoo options that we would usually use when starting Odoo:
(env15) $ odoo shell -c library.conf
This will initiate the usual server startup sequence in the terminal, but instead of launching an HTTP server listening for requests, it will start a Python prompt waiting for input.
This interactive command interface simulates the environment found inside a class
method, running under the OdooBot
superuser. The self
variable is available and is set to the OdooBot
superuser record object.
For example, these commands inspect the self
recordset:
>>> self res.users(1,) >>> self._name 'res.users' >>> self.name 'OdooBot...