How it works…
We generate a clean directory structure with clearly labeled directories and dedicated roles. We are using different directories to store the following:
- The code maintained by other people (in
src/
) - The local-specific code
filestore
of the instance
By having one virtualenv
environment per project, we are sure that the project's dependencies will not interfere with the dependencies of other projects that may be running a different version of Odoo or will use different third-party add-on modules, which require different versions of Python dependencies. This comes at the cost of a little disk space.
In a similar way, by using separate clones of Odoo and third-party add-on modules for our different projects, we are able to let each of these evolve independently and only install updates on the instances that need them, hence reducing the risk of introducing regressions.
The bin/odoo
script allows us to run the server without having to remember the various paths or activate the virtualenv
environment. This also sets the configuration file for us. You can add additional scripts in there to help you in your day-to-day work. For instance, you can add a script to check out the different third-party projects that you need to run your instance.
Regarding the configuration file, we have only demonstrated the bare minimum options to set up here, but you can obviously set up more, such as the database name, the database filter, or the port on which the project listens. Refer to Chapter 1, Installing the Odoo Development Environment, for more information on this topic.
Finally, by managing all of this in a Git repository, it becomes quite easy to replicate the setup on a different computer and share the development among a team.
Speedup tip
To facilitate project creation, you can create a template repository containing the empty structure, and fork that repository for each new project. This will save you from retyping the bin/odoo
script, the .gitignore
file, and any other template file you need (continuous integration configuration, README.md
, ChangeLog
, and so on).
There's more...
The development of complex modules requires various configuration options, which leads to updating the configuration file whenever you want to try any configuration option. Updating the configuration file frequently can be a headache, and to avoid this, an alternative way is to pass all configuration options from the command line, as follows:
- Activate
virtualenv
manually:$ source env/bin/activate
- Go to the Odoo source directory:
$ cd src/odoo
- Run the server:
./odoo-bin --addons-path=addons,../../local -d test-14 -i account,sale,purchase --log-level=debug
In step 3, we passed a few configuration options directly from the command line. The first is --add-ons-path
, which loads Odoo's core add-ons directory, addons
, and your add-ons directory, local
, in which you will put your own add-on modules. Option -d
will use the test-14
database or create a new database if it isn't present. The -i
option will install the account
, sale
, and purchase
modules. Next, we passed the log-level
option and increased the log level to debug
so that it will display more information in the log.
Note
By using the command line, you can quickly change the configuration options. You can also see live logs in the terminal. For all available options, refer to Chapter 1, Installing the Odoo Development Environment, or use the --help
command to view a list of all options and the description of each option.