Introducing odoo-venv
How to install and run Odoo?
This sounds like a simple question, but you would be surprised how many different valid answers exist depending on who you ask.
Here’s a non-exhaustive overview of the situation:
-
Odoo SA
-
* Maintains [DEB/RPM packages](https://nightly.odoo.com)- Maintains the official Odoo Docker Hub image: built on top of Ubuntu images and using their DEB package
-
OCA (Odoo Community Association)
-
* Docker image to run tests: [oca-ci](https://github.com/oca/oca-ci)- OCA addons are pushed to a PIP wheelhouse, enabling a PIP-only approach
-
Odoo Integrators
-
* Docker-based solutions-
* [Doodba](https://github.com/tecnativa/doodba)- Camptocamp: docker-odoo-project
-
Each approach has its merits, but the more layers of abstraction they rely on, the more complex and challenging local developments become.
At Trobz, however, we’ve chosen a simple venv-based approach: odoo-venv.
What we do at Trobz?
We prefer to run Odoo inside a Python virtual environment, it gives us more control, clarity and flexibility when:
-
Debugging issues locally
-
Understanding exactly what dependencies are installed
-
Switching between different Odoo versions or projects
But managing these virtual environments manually across different projects and use in each case with different dependency requirements quickly becomes tedious. That’s why we built odoo-venv.
How odoo-venv works?
odoo-venv is a small CLI tool designed to spin up isolated Odoo environments in seconds.
It standardizes how we create and manage these environments across different use cases at Trobz.
Key features
-
Creating a Python virtual environment with the correct Python version
-
Installing Odoo core dependencies
-
Installing dependencies from addon manifest
-
Managing presets for different types of Odoo projects
-
Filtering out problematic or unwanted dependencies
It’s Fast
Creating a Python virtual environment with the correct Python version. One of the biggest advantages of odoo-venv is its speed. Under the hood, it uses uv , an insanely fast modern Python package installer.
It means:
-
Package operations are 10-100x faster than traditional methods
-
You can iterate quickly without waiting for slow pip installs
In short, odoo-venv brings the simplicity of python-m venv with the power and speed of modern tooling.
How to use it?
The simplest way to use odoo-venv is with direct CLI arguments:
$ odoo-venv 17.0 \
--odoo-dir ~/code/odoo/odoo/17.0 \
--python-version 3.10 \
--extra-requirement "debugpy,ipython"
This creates a virtual environment for Odoo 17.0 with:
-
Python 3.10
-
Installing Odoo in editable mode
-
Installing Odoo dependencies
-
Extra tools: debugpy and ipython
Using Presets
For recurring configurations, it is recommended to utilize presets. The tool provides 4 out-of-box presets, each adapted to a specific use case.
Local
__
-
What does it do?
-
* Installs all dependencies from all modules (both from requirements.txt files and manifest files)-
Includes development tools: debugpy, ipython, pylint, coverage, etc.
-
Ignores gevent and greenlet from Odoo’s requirements (commonly cause troubles due to version conflicts)
-
-
Ideal for
-
* Exploratory development- Quick work on OCA modules
Demo
__
-
What does it do?
-
* Installs all dependencies from all available modules- Ensures users can install any module without missing dependencies
-
Ideal for
-
* Client demonstrations- UAT environment
Project
__
-
What does it do?
-
* Installs additional dependencies listed in projects- Keeps the environment minimal and predictable
-
Ideal for
-
* Production environments- Client-specific projects
CI
__
-
What does it do?
-
* Installs all dependencies from all modules- Includes extra dependencies for testing: websocket-client, coverage, pylint, etc
-
Ideal for
-
* CI pipelines
You can even have your own preset by defining it in the presets.toml file, which is located in ~/.local/share/odoo-venv.
Moreover, odoo-venv can also be used programmatically in Python scripts:
```
create_odoo_venv(
odoo_version="17.0",
odoo_dir="~/code/odoo/odoo/17.0",
venv_dir="./.venv",
python_version="3.10",
addons_paths=["~/code/oca/ web/17.0"],
install_addons_dirs_requirements=True,
extra_requirements=["debugpy", "ipython"],
)
```
__
Conclusion
__
In a world where Odoo deployment strategies often feel complex and fragmented, odoo-venv offers a refreshingly simple alternative.
Note that it works best when combined with another useful component of our stack: odoo-addons-path , introduced here.