This is the Mint System Odoo development environment.
This projects provides a highly opinionated way to develop Odoo modules. It features:
- Odoo Source: Checkout the Odoo Community and Enterprise Edition and start editing the source code.
- Docker Compose: Spin up a Odoo, Postgres and pgAdmin Docker container and experiment locally.
- Native: Start an Odoo server directly from the source.
- Import and Export Database: Use Odoo scripts to copy and restore a customer database to the local environment. Investigate issues and deploy the database at ease.
- Community Modules: The most common community modules are checked out when setting up the project.
- Customizing Snippets: Create snippets and push them to an Odoo database.
- Odoo Scripts: Develope scripts to patch Odoo code.
- Odoo Revisions: Snapshot the Odoo source at a specific date. See revisions for details.
- Odoo Image: Build and publish a custom Odoo Docker image. See README for details.
- Kubernetes: Deploy Odoo and Postgres to a local Kubernetes cluster.
- Develop Modules: Scaffold a new module, develop new Odoo features locally and much more.
- Credentials: Setup credentials to log into Odoo.
- Import Data: Import Odoo records from CSV.
The Odoo development environment has the following requirements:
- Docker
- Install Python 3.11+ with pyenv
- Install PostgreSQL
- bash/zsh alias
task='./task'
with optional bash/zsh completion.
You can also use Nix to setup the development requirements.
Install kind or minikube and kubectl to deploy Odoo to Kubernetes.
The usage section is a set of workflows. See task help
or task for details about the project commands.
Clone this repository.
git clone [email protected]:Mint-System/Odoo-Build.git
cd Odoo-Build
When working with Nix, run the nix-shell.
nix-shell
Checkout the Odoo version. Supported versions are: 13.0, 14.0, 15.0, 16.0, 17.0, 18.0
task checkout $VERSION
Install Odoo scripts.
task install-odoo-scripts
Decide wether you want to run Odoo in native mode (from source) or with Docker as a container.
Run Odoo from source. Currently supported OS: Ubuntu, Debian, Pop!_OS, Darwin
Init submodules and switch to the Odoo version.
task git-submodule-init
task git-submodule-switch $VERSION
Install Python and pip.
pyenv install
Install the python dependencies.
task install-native
Run database container only.
task start db
Initialize database.
task init-db
Start Odoo from source.
task start native
The browser will be opened automatically.
Create a new module.
task create-module addons/project/project_sprint
Add a new model.
task generate-module-model addons/project/project_sprint project.sprint
Add model security.
task generate-module-security addons/project/project_sprint project.sprint
Clone thirdparty repos into the thirdparty
folder.
To load modules from a thirdparty folder, set this env var in your .env
file:
ODOO_ADDONS_PATH=thirdparty/odoo-apps-partner-contact,../odoo-cd/untracked-odoo-apps
The paths will be appended to the Odoo config.
In your .env
file define this Odoo parameter env var:
ODOO_PARAM="--without-demo=all"
By default the database name is the current branch name.
To define the name, set this env var in your .env
file:
ODOO_DATABASE=odoo
To disable the browser open when starting the Odoo server edit the .env
file:
BROWSER_OPEN=false
Run Odoo with Docker container.
Set the Odoo addons path in your .env
file:
ODOO_ADDONS_PATH=/mnt/addons/,/mnt/oca/,/mnt/enterprise,/mnt/themes/
Run Docker Compose.
task start
Initialize database with the Odoo script.
Use docker-odoo-init help
to show all options.
docker-odoo-init -d odoo -i web
Open browser to http://localhost:8069 and login with admin:admin
.
docker-odoo-install -m show_db_name
Instructions that are true for Docker and native usage.
To change the log level of Odoo set this env var in your .env
file:
LOG_LEVEL=debug
Open database manager http://localhost:8000/ and login with [email protected]:admin
.
This removes containers and volumes.
task remove
task stop
task drop-db
Define the Postgres image in your .env
file:
POSTGRES_IMAGE=postgres:12-alpine
To build the Docker image setup these .env
vars:
ODOO_REVISION=16.0.2024.0405
DOCKER_REGISTRY=mint-system/
Checkout the Odoo revision.
task checkout-revision
Build the Odoo image.
task build
Publish the Odoo image.
task publish
Start mail server.
task start mail
Setup mail server config for Odoo.
task setup-mail
Run a local Kubernets cluster with kind or minikube.
Start Kubernetes with kind
.
task start-kind
Or start Kubernetes with minikube
.
task start-minikube
Ensure you have kubectl
installed and can access the cluster.
The following command applies the Odoo and Postgres manifests and initializes the Odoo database.
task k8s-apply
Problem
The checkout command fails tue to unregistered submdoules.
Solution
Remove the submodule with git rm
, f.e. git rm oca/dms
.
Problem
While starting the native server this error is thrown:
OSError: [Errno 24] inotify instance limit reached
Solution
Increase inotify watch limit.
sudo vi /etc/sysctl.conf
fs.inotify.max_user_watches=524288
fs.inotify.max_user_instances=256
sudo sysctl -p
Problem
Instance with auth_ldap
does not start.
ImportError: libldap_r-2.4.so.2: cannot open shared object file: No such file or directory
Solution
Reinstall with pip flags.
pip install python-ldap --force-reinstall --no-binary python-ldap
Problem
init-db
fails with psycopg2 errors on macOS / Darwin.
Solution
source task source
pip install psycopg2-binary --force
Problem
After switching the Odoo version with task checkout
the task
command fail with this error:
pkg_resources.DistributionNotFound: The 'odoo==XX.0' distribution was not found and is required by the application
Solution
The local Odoo package needs to be updated:
source task source
pip install -e odoo
Problem
After install the Pyhton dependencies and running Odoo the following error is thrown:
ImportError: lxml.html.clean module is now a separate project lxml_html_clean.
Install lxml[html_clean] or lxml_html_clean directly.
Solution
Pin the version lxml.
pip install lxml==4.9.3
Problem
After install the Pyhton dependencies and running Odoo the following error is thrown:
Traceback (most recent call last):
File "/home/janikvonrotz/Odoo-Build/venv17.0/bin/odoo", line 7, in <module>
exec(compile(f.read(), __file__, 'exec'))
File "/home/janikvonrotz/Odoo-Build/odoo/setup/odoo", line 5, in <module>
import odoo
File "/home/janikvonrotz/Odoo-Build/odoo/odoo/__init__.py", line 119, in <module>
from . import service
File "/home/janikvonrotz/Odoo-Build/odoo/odoo/service/__init__.py", line 5, in <module>
from . import model
File "/home/janikvonrotz/Odoo-Build/odoo/odoo/service/model.py", line 13, in <module>
from odoo.http import request
File "/home/janikvonrotz/Odoo-Build/odoo/odoo/http.py", line 279, in <module>
if parse_version(werkzeug.__version__) >= parse_version('2.0.2'):
^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'werkzeug' has no attribute '__version__'
Solution
pip install Werkzeug==2.2.2