diff --git a/11.0/Dockerfile b/11.0/Dockerfile index 5e5a63b8..ae15382f 100644 --- a/11.0/Dockerfile +++ b/11.0/Dockerfile @@ -77,7 +77,7 @@ ENV ODOO_VERSION=11.0 \ # the place where you put the data of your project (csv, ...) ODOO_DATA_PATH=/odoo/data \ DEMO=False \ - ADDONS_PATH=/odoo/local-src,/odoo/src/addons \ + ADDONS_PATH=/odoo/odoo/addons,/odoo/odoo/src/odoo/addons \ OPENERP_SERVER=/odoo/odoo.cfg ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/12.0/Dockerfile b/12.0/Dockerfile index eb924b8a..1dae07c3 100644 --- a/12.0/Dockerfile +++ b/12.0/Dockerfile @@ -76,7 +76,7 @@ ENV ODOO_VERSION=12.0 \ # the place where you put the data of your project (csv, ...) ODOO_DATA_PATH=/odoo/data \ DEMO=False \ - ADDONS_PATH=/odoo/local-src,/odoo/src/addons \ + ADDONS_PATH=/odoo/odoo/addons,/odoo/odoo/src/odoo/addons \ OPENERP_SERVER=/odoo/odoo.cfg ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/13.0/Dockerfile b/13.0/Dockerfile index 584c7e32..98a4b4d9 100644 --- a/13.0/Dockerfile +++ b/13.0/Dockerfile @@ -75,7 +75,7 @@ ENV ODOO_VERSION=13.0 \ # the place where you put the data of your project (csv, ...) ODOO_DATA_PATH=/odoo/data \ DEMO=False \ - ADDONS_PATH=/odoo/local-src,/odoo/src/addons \ + ADDONS_PATH=/odoo/odoo/addons,/odoo/odoo/src/odoo/addons \ OPENERP_SERVER=/odoo/odoo.cfg ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/14.0-bullseye/Dockerfile b/14.0-bullseye/Dockerfile index 1ee8c2e7..6d7143f1 100644 --- a/14.0-bullseye/Dockerfile +++ b/14.0-bullseye/Dockerfile @@ -77,7 +77,7 @@ ENV ODOO_VERSION=14.0 \ # the place where you put the data of your project (csv, ...) ODOO_DATA_PATH=/odoo/data \ DEMO=False \ - ADDONS_PATH=/odoo/local-src,/odoo/src/addons \ + ADDONS_PATH=/odoo/odoo/addons,/odoo/odoo/src/odoo/addons \ OPENERP_SERVER=/odoo/odoo.cfg ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/15.0/Dockerfile b/15.0/Dockerfile index 5e089710..6c618c29 100644 --- a/15.0/Dockerfile +++ b/15.0/Dockerfile @@ -77,7 +77,7 @@ ENV ODOO_VERSION=15.0 \ # the place where you put the data of your project (csv, ...) ODOO_DATA_PATH=/odoo/data \ DEMO=False \ - ADDONS_PATH=/odoo/local-src,/odoo/src/addons \ + ADDONS_PATH=/odoo/odoo/addons,/odoo/odoo/src/odoo/addons \ OPENERP_SERVER=/odoo/odoo.cfg ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/16.0/Dockerfile b/16.0/Dockerfile index 1e50b798..b6703dd8 100644 --- a/16.0/Dockerfile +++ b/16.0/Dockerfile @@ -76,7 +76,7 @@ ENV ODOO_VERSION=16.0 \ # the place where you put the data of your project (csv, ...) ODOO_DATA_PATH=/odoo/data \ DEMO=False \ - ADDONS_PATH=/odoo/local-src,/odoo/src/addons \ + ADDONS_PATH=/odoo/odoo/addons,/odoo/odoo/src/odoo/addons \ OPENERP_SERVER=/odoo/odoo.cfg ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/17.0/Dockerfile b/17.0/Dockerfile index cc5ccfd9..3b4f183e 100644 --- a/17.0/Dockerfile +++ b/17.0/Dockerfile @@ -76,7 +76,7 @@ ENV ODOO_VERSION=17.0 \ # the place where you put the data of your project (csv, ...) ODOO_DATA_PATH=/odoo/data \ DEMO=False \ - ADDONS_PATH=/odoo/local-src,/odoo/src/addons \ + ADDONS_PATH=/odoo/odoo/addons,/odoo/odoo/src/odoo/addons \ OPENERP_SERVER=/odoo/odoo.cfg ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/bin/docker-entrypoint.sh b/bin/docker-entrypoint.sh index e70b4bfb..63e90a8e 100755 --- a/bin/docker-entrypoint.sh +++ b/bin/docker-entrypoint.sh @@ -12,7 +12,7 @@ export PGAPPNAME=${HOSTNAME} # As docker-compose exec do not launch the entrypoint # init PG variable into .bashrc so it will be initialized -# when doing docker-compose exec odoo gosu odoo bash +# when doing docker-compose exec odoo odoo bash echo " export PGHOST=${DB_HOST} export PGPORT=${DB_PORT} diff --git a/bin/lint b/bin/lint index bd5fd5c2..44781586 100755 --- a/bin/lint +++ b/bin/lint @@ -1,4 +1,4 @@ #!/bin/bash set -e -flake8 /odoo/local-src --exclude=__init__.py +flake8 $LOCAL_CODE_PATH --exclude=__init__.py diff --git a/bin/list_dependencies.py b/bin/list_dependencies.py index ef908d7d..031f2140 100755 --- a/bin/list_dependencies.py +++ b/bin/list_dependencies.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # Provide a list of module which are dependencies -# of local-src modules excluding local-src modules +# of odoo/addons modules excluding odoo/addons modules # # Arguments: # list of module (coma separated), restrict list of @@ -13,17 +13,17 @@ import os import ast -LOCAL_SRC_DIR = os.path.join("/odoo", "local-src") +LOCAL_CODE_PATH = os.getenv('LOCAL_CODE_PATH',"/odoo/odoo/addons") dependencies = set() -local_modules = os.listdir(LOCAL_SRC_DIR) +local_modules = os.listdir(LOCAL_CODE_PATH) if len(sys.argv) > 1: modules = sys.argv[1].split(",") else: modules = local_modules for mod in modules: # read __manifest__ - manifest_path = os.path.join(LOCAL_SRC_DIR, mod, "__manifest__.py") + manifest_path = os.path.join(LOCAL_CODE_PATH, mod, "__manifest__.py") if not os.path.isfile(manifest_path): continue with open(manifest_path) as manifest: diff --git a/bin/migrate b/bin/migrate index 3fe7666e..26139c1c 100755 --- a/bin/migrate +++ b/bin/migrate @@ -4,11 +4,9 @@ set -e if ! PGPASSWORD=$DB_PASSWORD psql -lqtA -h $DB_HOST -U $DB_USER | grep -q "^$DB_NAME|"; then PGPASSWORD=$DB_PASSWORD createdb -h $DB_HOST -U $DB_USER -O $DB_USER $DB_NAME fi - -CONFIGFILE=/odoo/migration.yml MARABUNTA_DB_HOST=$DB_HOST \ MARABUNTA_DATABASE=$DB_NAME \ MARABUNTA_DB_USER=$DB_USER \ MARABUNTA_DB_PASSWORD=$DB_PASSWORD \ MARABUNTA_DB_PORT=$DB_PORT \ -unbuffer marabunta --migration-file $CONFIGFILE +unbuffer marabunta --migration-file $MIGRATION_CONFIG_FILE diff --git a/bin/runtests b/bin/runtests index b8acefd7..f559a12c 100755 --- a/bin/runtests +++ b/bin/runtests @@ -1,6 +1,6 @@ #!/bin/bash # -# Run unit tests of local-src modules +# Run unit tests of odoo/addons modules # # mainly used from Travis, # it creates a database, @@ -30,11 +30,10 @@ set -e wait_postgres.sh -LOCAL_SRC_DIR=/odoo/local-src CACHE_DIR=${CACHE_DIR:=/tmp/cachedb} if [ -z $1 ]; then - LOCAL_ADDONS=$(find ${LOCAL_SRC_DIR}/* -maxdepth 0 -type d -and -not -name server_environment_files -printf "%f\n" | + LOCAL_ADDONS=$(find ${LOCAL_CODE_PATH}/* -maxdepth 0 -type d -and -not -name server_environment_files -printf "%f\n" | awk -vORS=, '{print $1}' | sed 's/,$/\n/') else @@ -73,7 +72,7 @@ else pg_dump -Fp -d $DB_NAME_TEST -O -f "$CACHED_DUMP" fi fi -echo "🔧🔧 Install local-src modules 🔧🔧" +echo "🔧🔧 Install odoo/addons modules 🔧🔧" odoo --stop-after-init --workers=0 --database $DB_NAME_TEST --test-enable --log-level=test --log-handler=":INFO" --without-demo="" --db-filter=$DB_NAME_TEST -i ${LOCAL_ADDONS} dropdb ${DB_NAME_TEST} diff --git a/bin/testdb-gen b/bin/testdb-gen index e4a1be4a..96bf0975 100755 --- a/bin/testdb-gen +++ b/bin/testdb-gen @@ -16,5 +16,5 @@ fi echo "creating database ${DB_NAME}" createdb -h ${DB_HOST} -O ${DB_USER} ${DB_NAME} -gosu odoo odoo --stop-after-init --workers=0 --log-level=warn --without-demo="" "$@" +odoo --stop-after-init --workers=0 --log-level=warn --without-demo="" "$@" echo "done" diff --git a/bin/testdb-update b/bin/testdb-update index a260d82c..3be15410 100755 --- a/bin/testdb-update +++ b/bin/testdb-update @@ -15,5 +15,5 @@ if ! psql -lqtA -h ${DB_HOST} | grep -q "^$DB_NAME|"; then fi echo "updating database ${DB_NAME}" -gosu odoo odoo --stop-after-init --workers=0 --log-level=warn --without-demo="" "$@" +odoo --stop-after-init --workers=0 --log-level=warn --without-demo="" "$@" echo "done" diff --git a/example/odoo/Dockerfile b/example/Dockerfile similarity index 73% rename from example/odoo/Dockerfile rename to example/Dockerfile index b5f89f26..7c6bf1a0 100644 --- a/example/odoo/Dockerfile +++ b/example/Dockerfile @@ -8,9 +8,8 @@ MAINTAINER Camptocamp # 2. or adding each directory, this solution will reduce the build and download # time of the image on the server (layers are reused) RUN mkdir -p /odoo/src/odoo -COPY ./src /odoo/src/odoo -COPY ./external-src /odoo/external-src -COPY ./local-src /odoo/local-src +COPY ./odoo/src/odoo /odoo/src/odoo +COPY ./odoo/addons /odoo/odoo/addons COPY ./data /odoo/data COPY ./songs /odoo/songs COPY ./setup.py /odoo/ @@ -26,11 +25,11 @@ RUN set -x; \ COPY ./requirements.txt /odoo/ USER odoo -RUN pip install -e /odoo -RUN pip install -e /odoo/src/odoo +WORKDIR /odoo +RUN pip install --user -e . +RUN pip install --user -r requirements.txt # Project's specifics packages -RUN cd /odoo && pip install -r requirements.txt -ENV ADDONS_PATH=/odoo/local-src,/odoo/src/odoo/addons +ENV ADDONS_PATH=/odoo/odoo/addons,/odoo/src/odoo/addons diff --git a/example/odoo/Dockerfile-onbuild b/example/Dockerfile-onbuild similarity index 87% rename from example/odoo/Dockerfile-onbuild rename to example/Dockerfile-onbuild index acfaf009..752924f3 100644 --- a/example/odoo/Dockerfile-onbuild +++ b/example/Dockerfile-onbuild @@ -12,4 +12,4 @@ RUN set -x; \ COPY ./requirements.txt /odoo/ RUN cd /odoo && pip install -r requirements.txt -ENV ADDONS_PATH=/odoo/local-src,/odoo/src/addons +ENV ADDONS_PATH=/odoo/odoo/addons,/odoo/src/addons diff --git a/example/README.md b/example/README.md index efca18a0..fbf4ff89 100644 --- a/example/README.md +++ b/example/README.md @@ -8,7 +8,7 @@ Follow the steps: 1. Create directories. This is mandatory, they will be copied in the image - mkdir -p odoo/external-src odoo/local-src odoo/data odoo/songs + mkdir -p odoo/addons data songs 2. Add a submodule for Odoo (official or OCA/OCB) @@ -16,10 +16,10 @@ Follow the steps: git submodule add git@github.com:odoo/odoo.git odoo/src 3. Optionally add submodules for external addons in `odoo/external-src` - + git submodule add git@github.com:OCA/server-tools.git odoo/external-src/server-tools -4. Optionally add custom addons in `odoo/local-src` +4. Optionally add custom addons in `odoo/addons` 6. Create the Dockerfile, the bare minimum being (see also [the example file](odoo/Dockerfile) that installs additional dependencies): @@ -27,7 +27,7 @@ Follow the steps: FROM camptocamp/odoo-project:11.0 MAINTAINER - ENV ADDONS_PATH=/odoo/local-src,/odoo/external-src/server-tools,/odoo/src/addons + ENV ADDONS_PATH=/odoo/odoo/addons,/odoo/external-src/server-tools,/odoo/src/odoo/addons 7. Build your image diff --git a/example/odoo/data/images/logo.png b/example/data/images/logo.png similarity index 100% rename from example/odoo/data/images/logo.png rename to example/data/images/logo.png diff --git a/example/docker-compose.yml b/example/docker-compose.yml index eb30aa2a..db301c4a 100644 --- a/example/docker-compose.yml +++ b/example/docker-compose.yml @@ -24,6 +24,7 @@ services: - ADMIN_PASSWD=# set me - RUNNING_ENV=dev - LOG_HANDLER=:WARN + - LOCAL_CODE_PATH=/odoo/odoo/addons - MARABUNTA_MODE=demo # could be 'full' for the db with all the data - MARABUNTA_ALLOW_SERIE=True # should not be set in production diff --git a/example/odoo/migration.yml b/example/migration.yml similarity index 100% rename from example/odoo/migration.yml rename to example/migration.yml diff --git a/example/odoo/local-src/README.md b/example/odoo/addons/README.md similarity index 100% rename from example/odoo/local-src/README.md rename to example/odoo/addons/README.md diff --git a/example/odoo/local-src/dummy_test/__init__.py b/example/odoo/addons/dummy_test/__init__.py similarity index 100% rename from example/odoo/local-src/dummy_test/__init__.py rename to example/odoo/addons/dummy_test/__init__.py diff --git a/example/odoo/local-src/dummy_test/__openerp__.py b/example/odoo/addons/dummy_test/__manifest__.py similarity index 100% rename from example/odoo/local-src/dummy_test/__openerp__.py rename to example/odoo/addons/dummy_test/__manifest__.py diff --git a/example/odoo/local-src/dummy_test/tests/__init__.py b/example/odoo/addons/dummy_test/tests/__init__.py similarity index 100% rename from example/odoo/local-src/dummy_test/tests/__init__.py rename to example/odoo/addons/dummy_test/tests/__init__.py diff --git a/example/odoo/local-src/dummy_test/tests/test_dummy.py b/example/odoo/addons/dummy_test/tests/test_dummy.py similarity index 100% rename from example/odoo/local-src/dummy_test/tests/test_dummy.py rename to example/odoo/addons/dummy_test/tests/test_dummy.py diff --git a/example/odoo/external-src/README.md b/example/odoo/external-src/README.md deleted file mode 100644 index 43011faa..00000000 --- a/example/odoo/external-src/README.md +++ /dev/null @@ -1 +0,0 @@ -Here you should have OCA or other repositories as submodules. diff --git a/example/pyproject.toml b/example/pyproject.toml new file mode 100644 index 00000000..fcff93b5 --- /dev/null +++ b/example/pyproject.toml @@ -0,0 +1,21 @@ +[build-system] +requires=['setuptools-odoo', 'wheel', "setuptools>=67.0"] + +[tool.black] +line-length = 88 +skip-string-normalization = 'True' +include = '\.pyi?$' +exclude = ''' +/( + \.git + | \.mypy_cache + | \.tox + | \.venv + | src/odoo + | src/enterprise + | odoo/paid-modules + | data +)/ +| /__openerp__.py +| /__manifest__.py +''' diff --git a/example/odoo/requirements.txt b/example/requirements.txt similarity index 53% rename from example/odoo/requirements.txt rename to example/requirements.txt index 6ea49239..229f6695 100644 --- a/example/odoo/requirements.txt +++ b/example/requirements.txt @@ -1,2 +1,6 @@ # project's packages, customize for your needs: unidecode==0.4.14 +setuptools-odoo +setuptools>=67.0 +wheel +-e /odoo/src/odoo diff --git a/example/setup.py b/example/setup.py new file mode 100644 index 00000000..832ea693 --- /dev/null +++ b/example/setup.py @@ -0,0 +1,15 @@ +from setuptools import find_packages, setup + +setup( + name="odoo-project", + version='1.0.0', + description="Odoo Project", + license='GNU Affero General Public License v3 or later (AGPLv3+)', + author="Camptocamp", + author_email="info@camptocamp.com", + url="www.camptocamp.com", + packages=['songs'] + ['songs.%s' % p for p in find_packages('./songs')], + include_package_data=True, + odoo_addons=True, +) + diff --git a/example/odoo/songs/__init__.py b/example/songs/__init__.py similarity index 100% rename from example/odoo/songs/__init__.py rename to example/songs/__init__.py diff --git a/example/odoo/songs/install/__init__.py b/example/songs/install/__init__.py similarity index 100% rename from example/odoo/songs/install/__init__.py rename to example/songs/install/__init__.py diff --git a/example/odoo/songs/install/base.py b/example/songs/install/base.py similarity index 95% rename from example/odoo/songs/install/base.py rename to example/songs/install/base.py index ad71517f..650077bf 100644 --- a/example/odoo/songs/install/base.py +++ b/example/songs/install/base.py @@ -30,5 +30,5 @@ def setup_company(ctx, req): def main(ctx): """Create demo data""" - req = Requirement.parse("my-project-name") + req = Requirement.parse("odoo-project") setup_company(ctx, req) diff --git a/example/odoo/songs/install/demo.py b/example/songs/install/demo.py similarity index 100% rename from example/odoo/songs/install/demo.py rename to example/songs/install/demo.py diff --git a/example/test-compose.yml b/example/test-compose.yml index 767573b8..f64a942a 100644 --- a/example/test-compose.yml +++ b/example/test-compose.yml @@ -1,18 +1,17 @@ # Composition used to run automated tests on the images # Used by the Makefile at the repository's root -version: '2' +version: '3.8' services: odoo: - build: ./odoo/ + build: . depends_on: - db - kwkhtmltopdf volumes: - "data-odoo:/data/odoo" - - "./odoo/src/odoo:/odoo/src/odoo/odoo" - - "./odoo/src/addons:/odoo/src/odoo/addons" + - "./odoo/addons:/odoo/odoo/addons" environment: - DB_USER=odoo - DB_PASS=odoo @@ -22,6 +21,8 @@ services: - MARABUNTA_MODE=demo # could be 'full' for the db with all the data - KWKHTMLTOPDF_SERVER_URL=http://kwkhtmltopdf:8080 - ODOO_REPORT_URL=http://odoo:8069 + - LOCAL_CODE_PATH=/odoo/odoo/addons + - MIGRATION_CONFIG_FILE=/odoo/migration.yml # cached database dumps config for `runmigration` and `runtests` - CREATE_DB_CACHE=false # set it to 'true' to create dumps - LOAD_DB_CACHE=true # by default will always search for existing dumps diff --git a/test.sh b/test.sh index b63551d5..a6492596 100755 --- a/test.sh +++ b/test.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -Eeuo pipefail +set -Exeuo pipefail # # Run tests on the image @@ -62,11 +62,18 @@ cd "$TMP" echo '>>> Downloading Odoo src' rm -rf "$TMP/odoo/src" wget -nv -O /tmp/odoo.tar.gz "$ODOO_URL" -tar xfz /tmp/odoo.tar.gz -C odoo/ -mv "odoo/odoo-$VERSION" odoo/src -ls odoo/src +mkdir -p odoo/src +tar xfz /tmp/odoo.tar.gz -C odoo/src +mv "odoo/src/odoo-$VERSION" odoo/src/odoo +ls odoo/src/odoo echo '>>> Run test for base image' -sed "s|FROM .*|FROM ${IMAGE_LATEST}|" -i odoo/Dockerfile +sed "s|FROM .*|FROM ${IMAGE_LATEST}|" -i Dockerfile +sed "s|version=.*|version=""'""${VERSION}"".1.0.0""'"",|" -i setup.py +sed "s|\(.version.: .\)[0-9.]*\(.*\)|\\1$VERSION.0.0.0\\2|" -i odoo/addons/dummy_test/__manifest__.py +echo $VERSION.0.0.0 > VERSION + +cat setup.py +cat odoo/addons/dummy_test/__manifest__.py mkdir .cachedb echo '>>> * migration: standard' @@ -79,10 +86,10 @@ docoruncmd odoo dropdb odoodb echo '>>> * migration: use the dump and migrate to new version' docorunmigration -e LOAD_DB_CACHE="true" docodown -echo " - version: 15.0.1" >>odoo/migration.yml -echo " operations:" >>odoo/migration.yml -echo " post:" >>odoo/migration.yml -echo " - anthem songs.install.demo::create_partners" >>odoo/migration.yml +echo " - version: 15.0.1" >>migration.yml +echo " operations:" >>migration.yml +echo " post:" >>migration.yml +echo " - anthem songs.install.demo::create_partners" >>migration.yml docoruncmd odoo dropdb odoodb echo '>>> * migration: use a ceil version'