diff --git a/CHANGELOG.md b/CHANGELOG.md index 87c89d23..6052a12d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file. The format * New command `exec` to run commands in containers. * New env var to include and exclude modules for tests. * Command `reset-venv`. +* Another Odoo image script `update-translations`. ### Fixed diff --git a/compose.yml.template b/compose.yml.template index 731a6b87..626afe6e 100644 --- a/compose.yml.template +++ b/compose.yml.template @@ -65,6 +65,7 @@ services: TEST_ADDONS_DIR: ${TEST_ADDONS_DIR} TEST_INCLUDE: ${TEST_INCLUDE} TEST_EXCLUDE: ${TEST_EXCLUDE} + AUTO_UPDATE_TRANSLATIONS: ${AUTO_UPDATE_TRANSLATIONS} ports: - "${ODOO_PORT}:${ODOO_PORT}" volumes: diff --git a/images/odoo/Dockerfile b/images/odoo/Dockerfile index 9d937f90..6fe069ad 100644 --- a/images/odoo/Dockerfile +++ b/images/odoo/Dockerfile @@ -138,7 +138,7 @@ COPY --from=builder /opt/odoo /opt/odoo # Setup environment path ENV PATH=/opt/odoo-venv/bin:$PATH -ENV ADDONS_PATH=/opt/odoo/addons,/mnt/extra-addons +ENV ADDONS_PATH=/opt/odoo/addons # Copy entrypoint scripts and Odoo configuration file COPY ./bin/setup-mail /usr/local/bin/ diff --git a/images/odoo/README.md b/images/odoo/README.md index 73e781a4..bc36a835 100644 --- a/images/odoo/README.md +++ b/images/odoo/README.md @@ -28,7 +28,7 @@ Source: The Mint System Odoo image runs with a very basic configuration, but can also be highly customized with environment variables. -### Base +### Minimal The following `compose.yml` is a minimal setup: @@ -43,7 +43,6 @@ services: PGHOST: db PGUSER: odoo PGPASSWORD: odoo - PGPORT: 5432 ODOO_ADDONS_PATH: /mnt/addons/,/mnt/enterprise/,/mnt/oca/,/mnt/themes/ ports: - "127.0.0.1:8069:8069" @@ -134,6 +133,7 @@ services: TEST_ADDONS_DIR: /mnt/oca/partner-contact TEST_INCLUDE: partner_firstname TEST_EXCLUDE: partner_fax + AUTO_UPDATE_TRANSLATIONS: True ports: - "127.0.0.1:8069:8069" volumes: @@ -219,6 +219,14 @@ docker compose run --rm odoo update-modules This will start a detached Odoo process and updates modules that have a different checksum. +Updating module translations is simple: + +```bash +docker compose run --rm odoo update-translations +``` + +Existing translations will be overwritten. + ### Analyze With the [Manifestoo](https://github.com/acsone/manifestoo) cli you can query the module manifest files. @@ -372,7 +380,10 @@ With the `module_change_auto_install` module you can disable the auto installati The container uses [click-odoo-contrib](https://github.com/acsone/click-odoo-contrib) to update Odoo modules. The auto update is disabled by default. -* `AUTO_UPDATE_MODULES` If enabled modules will updated when the container is started. Requires `ODOO_DATABASE` and `ODOO_ADDONS_PATH`. Default is `False`. +* `AUTO_UPDATE_MODULES` If enabled modules will updated when the container is started. Default is `False`. +* `AUTO_UPDATE_TRANSLATIONS` If enabled translatiosn will be updated when the container starts. Default is `False`. + +Both options require `ODOO_DATABASE` and `ODOO_ADDONS_PATH`. ### Test @@ -423,12 +434,14 @@ See [Odoo Build > Build and publish container image](https://odoo.build/#build-a The most important image paths are: * `/etc/odoo` Contains the `odoo.conf` and `odoo.conf.template` files. +* `/var/lib/odoo ` Odoo data folder. * `/var/lib/odoo/filestore` For every database name Odoo create a filestore. * `/var/lib/odoo/sessions` Location where werkzeug stores session information. * `/var/lib/odoo/git` The cloned module repos are stored here. * `/var/lib/odoo/enterprise` Odoo Enterprise modules are downloaded to this folder. * `/opt/odoo-venv` This is where Python packages are installed. * `/mnt/extra-addons` Module folders are loaded from this path by default. +* `/opt/odoo/addons` Here are the Odoo Community Edition modules. ### Capture memory profile diff --git a/images/odoo/bin/set-addons-path b/images/odoo/bin/set-addons-path index f4d336eb..40965fa2 100755 --- a/images/odoo/bin/set-addons-path +++ b/images/odoo/bin/set-addons-path @@ -1,5 +1,10 @@ #!/bin/bash +# Add extra addons path to addons path +if [ -d "/mnt/extra-addons" ]; then + ODOO_ADDONS_PATH="/mnt/extra-addons,$ODOO_ADDONS_PATH" +fi + # Add git path to addons path if [ -n "$ADDONS_GIT_REPOS" ] && [ -d "/var/lib/odoo/git" ]; then ODOO_ADDONS_PATH="/var/lib/odoo/git,$ODOO_ADDONS_PATH" @@ -11,7 +16,6 @@ if [ -n "$TEST_ADDONS_DIR" ]; then fi if [ -n "$ODOO_ADDONS_PATH" ]; then - entrypoint-log "Resolve addons path: $ODOO_ADDONS_PATH" # Search for module manifest files and return list of module paths diff --git a/images/odoo/bin/update-modules b/images/odoo/bin/update-modules index 21fc911d..2de5973d 100755 --- a/images/odoo/bin/update-modules +++ b/images/odoo/bin/update-modules @@ -2,7 +2,7 @@ source set-addons-path -if [ -n "$ODOO_DATABASE" ]; then - entrypoint-log "Run click-odoo-update." - (exec click-odoo-update --addons-path="${ADDONS_PATH}" -d "$ODOO_DATABASE" ) || true +if [ -n "$ADDONS_PATH" ] && [ -n "$ODOO_DATABASE" ]; then + entrypoint-log "Run click-odoo-update for: $ADDONS_PATH" + (exec click-odoo-update --addons-path="$ADDONS_PATH" -d "$ODOO_DATABASE" ) || true fi diff --git a/images/odoo/bin/update-translations b/images/odoo/bin/update-translations new file mode 100755 index 00000000..06360644 --- /dev/null +++ b/images/odoo/bin/update-translations @@ -0,0 +1,14 @@ +#!/bin/bash + +source set-addons-path + +if [ -n "$ODOO_DATABASE" ]; then + entrypoint-log "Updating translations for all active languages and installed modules." + (exec odoo shell --database "$ODOO_DATABASE" --config "$ODOO_RC" << EOF +for lang in env['res.lang'].search([]): + env['ir.module.module'].search([('state', '=', 'installed')])._update_translations(lang.code, overwrite=True) +env.cr.commit() +print('Translations updated successfully') +EOF +) || true +fi diff --git a/images/odoo/entrypoint.sh b/images/odoo/entrypoint.sh index 6c45404d..7737cc14 100755 --- a/images/odoo/entrypoint.sh +++ b/images/odoo/entrypoint.sh @@ -59,6 +59,11 @@ if [ "$AUTO_UPDATE_MODULES" = True ]; then update-modules fi +AUTO_UPDATE_TRANSLATIONS="${AUTO_UPDATE_TRANSLATIONS:=False}" +if [ "$AUTO_UPDATE_TRANSLATIONS" = True ]; then + update-translations +fi + case "$1" in memray) shift diff --git a/task b/task index a59921b9..9114e7ab 100755 --- a/task +++ b/task @@ -1212,6 +1212,7 @@ function test-project() { export SESSION_DB_URI=postgres://odoo:odoo@db/test export MODULE_AUTO_INSTALL_DISABLED=odoo_test_xmlrunner export AUTO_UPDATE_MODULES=True + export AUTO_UPDATE_TRANSLATIONS=True export MAIL_DEFAULT_FROM="test" export BROWSER_OPEN=false export TEST_ADDONS_DIR=/mnt/oca/partner-contact @@ -1237,7 +1238,9 @@ function test-project() { export ODOO_URL="http://localhost:8069" export ODOO_USERNAME=test export ODOO_PASSWORD=test - create-odoo-env test + if ! show-env test; then + create-odoo-env test + fi show-env test test-xmlrpc test @@ -1248,7 +1251,6 @@ function test-project() { remove-snippet test snippets/base.view_partner_form.show_type.xml echo -e "\033[38;5;214mTEST\033[0m: Check module auto update." - # CHECKSUM1=$(images/odoocli/bin/odoocli --method 'read' --model 'ir.config_parameter' --domain "[('key', '=', 'module_auto_update.installed_checksums')]" --field 'value' | jq '.partner_firstname') sed -i 's/First name/Firstname/g' oca/partner-contact/partner_firstname/models/res_partner.py restart odoo until curl --silent --fail "http://localhost:8069/web/login" &> /dev/null; do @@ -1258,6 +1260,10 @@ function test-project() { docker logs odoo docker logs odoo 2>&1 | $GREP "Run click-odoo-update." + echo -e "\033[38;5;214mTEST\033[0m: Check translations auto update." + sed -i 's/Nachname/Familienname/g' oca/partner-contact/partner_firstname/i18n/de.po + restart odoo + echo -e "\033[38;5;214mTEST\033[0m: Drop the test database." drop-db test