Waft is a wrapper for installing Odoo.
In this, it is similar to:
The Anybox buildout recipe, yet instead of relying on the aging buildout tool, it relies on pip to install Python modules and git-aggregator for Odoo module branch aggregation.
Doodba, yet instead of using Docker, it runs native on your Linux system and keeps all relevant files in one folder.
In fact, many scripts are borrowed from Doodba.
We needed a tool that could replace buildout, but did not want to switch to a Docker development workflow.
.python-version
using pyenv
requirements.txt
in a virtual environment in .venv
gitaggregrator
to collect Odoo modules from different git
repositories and branches as defined in repos.yaml
in custom/src/XXX/YYY
foldersauto/odoo.conf
./upgrade
, ./install
, ./shell
, waftlib/bin/reset-password
, …You’ll need to take care of these yourself.
As for the system requirements, take a look at the files in this folder or also checkout the pyenv prerequisites
Note: when you do want to use an existing python version or system python, you can create a
virtual environment in the root directory by using $ python -m venv .venv
or
if you have an existing virtualenv binary: `$ virtualenv .venv.
Clone the waft template project and run bootstrap:
git clone https://github.com/sunflowerit/waft
cd waft && ./bootstrap
It will clone waftlib and exit with a suggestion to do more things, which we will do now.
Select an Odoo version that you want to use, for example 13.0
Create your secret environment variables file from default environment variables template file and rerun bootstrap:
cp waftlib/templates/13.0/.env-shared .env-secret
./bootstrap
When successful, now we can prepare for building Odoo:
vi common/conf.d/odoo.conf
.vi common/conf.d/override-odoo.conf
. You can use ENVIRONMENT variables herevi .env-shared
that apply for all clones of this instance, you can replace the link to templet file with a regular file and modify it as you like. NOTE: don’t put secret variables values in this file..env-shared
by putting it in .env-secret
such as DBFILTER, PGDATABASE, PGUSER etccustom/src/repos.yaml
, if you like to modify it replace the link with a regular file.custom/sec/addons.yaml
, if you like to modify it replace the link with a regular file../build
Now we can create database and run Odoo:
./install mydatabase web
./run
At this point when you know the project configuration is complete, you can push it back to Git, but not to the waft
repository, but to your project’s repository, for example to a branch named build
:
git rm -Rf .git
git init
git add .
git commit -a "[ADD] Initial project commit"
git checkout -b build
git remote add origin git@github.com/mycompany/myproject
git push --set-upstream origin build
Now everyone who wants to work with your project can:
.env-secret
to match their local environment (Postgres connection details, etc)./bootstrap
and ./build
, and get going.To add a new Python module:
# edit requirements.txt, add the module you want
./build
OR:
# edit requirements.txt, add the module you want
source .venv/bin/activate
pip install -r requirements.txt
# Then commit and push to share the new requirements.txt with colleagues
To add a new Odoo module:
vi custom/src/repos.yaml
vi custom/src/addons.yaml
./build
To start an Odoo shell:
./shell
# Now you get a shell that has `env` object
To start a click-odoo script:
source .venv/bin/activate
click-odoo -c ./auto/odoo.conf my-script.sh
To run any other custom Odoo command:
source .venv/bin/activate
odoo -c auto/odoo.conf --help
v.21.05.10
to v.21.09.22
version:pipenv run pip freeze > requirements.txt
, you don’t need to do that if you didn’t modify the default Pipfile.waftlib/templates/13.0/.python-version #for odoo 13.0 in example
you should create a regular .python-version
file in the main directory with your python version. you don’t need to do that if you didn’t modify the default Pipfile.Pipfile
.Pipfile.lock
..venv
directory..env-shared
remove it.common/conf.d/odoo.cfg
remove it.custom/src/addons.yaml
remove it.custom/src/repos.yaml
remove it./usr/bin/curl https://raw.githubusercontent.com/sunflowerit/waft/fec170fd456a371b3468b8d9eef505bf079af40c/bootstrap -o bootstrap
/usr/bin/curl https://raw.githubusercontent.com/sunflowerit/waft/fec170fd456a371b3468b8d9eef505bf079af40c/.gitignore -o .gitignore
./bootstrap
./build
You can! Just define a Dockerfile
at the root of your project and do all things you need to do to get a working OS that supports Waft. For example: use Ubuntu 20.04
base image, install npm
, lessc
, libpython-dev
, wkhtmltopdf
, Postgres
, run ./bootstrap
, ./build
, ./run
.
waftlib
scripts and I want to override themYou can! All scripts are symlinks pointing into waftlib, and the symlinks are stored in the project’s Git. Meaning you can delete them and override them with your own script. Example:
git rm ./bootstrap
cp waftlib/bootstrap .
vi bootstrap # edit like you wish
git add bootstrap
git commit -m "[UPD] use modified Bootstrap script"
Note that when you do this, you won’t subscribe to Waft updates anymore, so if there is a change or fix in waftlib/bootstrap
, you will need to update it in your project manually.
You can also set up a dev environment with Pycharm. This allows you to develop locally if you wish to. Firstly:
Follow the setup steps and make sure your odoo environment is ready.
Install latest PyCharm.
Once the above steps are set, then do the following under Pycharm:
Go to your project settings (i.e waft folder project) under File menu and select Python Interpreter.
Click on Add, select existing environment, this is because, if you followed the setup steps above, you should have a hidden .venv folder under waft folder
If you have the hidden .venv folder, then select python under bin folder and save the settings, you can also make it available for other projects (option).
Click on The Add configuration option, select left + sign to add python configuration.
Give the python configuration a name, then select script path option, and add a script from the hidden .venv folder, under bin, choose the odoo file. This is like odoo-bin.py/openerp.py in odoo folders. You can add run script to make work easier, it is a script that runs odoo instance.
Add odoo parameters if any e.g -c odoo-config-path/odoo.conf --workers=0
etc.
Lastly and importantly, add the existing virtual env under python interpreter, that you had earlier configured in the first step, and run.