feat(odoo-image): add support for updating translations
This commit is contained in:
9 files changed
+54
-10
No files matched your search
@@ -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
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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/
|
||||
|
||||
+16
-3
@@ -28,7 +28,7 @@ Source: <https://github.com/Mint-System/Odoo-Build/tree/main/images/odoo/>
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
Executable
+14
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user