[REF] l10n_fr_account: host custom migration scripts in a dedicated `--upgrade-path`
Custom migration scripts for a core module used to require copying the whole module into ``versions/18.0/addons/`` so its ``migrations/`` folder would be picked up. Because the migration container mounts that copy with priority (``--addons-path=mig,addons``) and ``get_module_path`` returns the first match, the copy fully shadowed the core module — dragging along its entire data/models just to carry one script. Instead, inject the scripts through a dedicated OpenUpgrade ``upgrade_path``: - New ``versions/18.0/scripts/l10n_fr_account/18.0.2.2/`` holding ``pre-migration-0k-fix-orphan-expressions.py`` (converted to the ``@openupgrade.migrate()`` / ``migrate(env, version)`` convention) and ``post-migration-0k-vat-box25.py`` + ``noupdate_changes.xml`` that reapply the box 25 VAT-report customization via ``openupgrade.load_data``. - ``config/compose.yml``: mount it as ``/opt/odoo/auto/upgrade`` for ou18. - ``versions/18.0/upgrade.sh``: pass ``--upgrade-path=/opt/odoo/auto/upgrade,/opt/odoo/auto/addons/openupgrade_scripts/scripts``. Odoo appends every path to ``odoo.upgrade.__path__`` and concatenates the per-version scripts, so our scripts run IN ADDITION to the native ones; the native path is listed explicitly because ``--upgrade-path`` overrides ``config['upgrade_path']`` which ``openupgrade_framework`` only sets when empty. Files are named with a ``-0k-`` marker so they never collide with the native ``pre-migration.py`` / ``post-migration.py``. This removes the need for the shadowing module copy entirely. Also ignore ``__pycache__``/``*.pyc``.
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
run_compose run -p 8018:8069 ou18 --config=/opt/odoo/auto/odoo.conf --stop-after-init -u all --workers 0 --log-level=debug --max-cron-threads=0 --limit-time-real=10000 --database=ou18 --load=base,web,openupgrade_framework
|
||||
# --upgrade-path lists BOTH our custom migration scripts and OpenUpgrade's
|
||||
# native ones. Passing --upgrade-path overrides config['upgrade_path'], and
|
||||
# openupgrade_framework only sets that default when it is empty; so we must
|
||||
# include the native openupgrade_scripts/scripts path explicitly, otherwise the
|
||||
# native migration scripts would no longer run. Odoo appends every listed path
|
||||
# to odoo.upgrade.__path__ and concatenates (does not override) the scripts
|
||||
# found per module/version, so our script runs IN ADDITION to the native ones.
|
||||
run_compose run -p 8018:8069 ou18 --config=/opt/odoo/auto/odoo.conf --stop-after-init -u all --workers 0 --log-level=debug --max-cron-threads=0 --limit-time-real=10000 --database=ou18 --load=base,web,openupgrade_framework --addons-path=/opt/odoo/auto/mig,/opt/odoo/auto/addons --upgrade-path=/opt/odoo/auto/upgrade,/opt/odoo/auto/addons/openupgrade_scripts/scripts
|
||||
|
||||
Reference in New Issue
Block a user