sunflowerit / waftlib

Apache License 2.0
6 stars 13 forks source link

Waft Odoo installation method

Waft is a wrapper for installing Odoo.

In this, it is similar to:

In fact, many scripts are borrowed from Doodba.

Why?

We needed a tool that could replace buildout, but did not want to switch to a Docker development workflow.

What does it do

What it does not do (or: prerequisites)

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.

Setup a waft project

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:

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:

Usage

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

Upgrade waftlib from v.21.05.10 to v.21.09.22 version:

What if I still want to use Docker?

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.

What if I don't like the waftlib scripts and I want to override them

You 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.

Setting up a Development Environment (PyCharm)

You can also set up a dev environment with Pycharm. This allows you to develop locally if you wish to. Firstly: