Commit Graph

12 Commits

Author SHA1 Message Date
Stéphan Sainléger
803ae858ea [REM] pre_upgrade: delete obsolete `contract_payment_mode` before 18.0 load
``contract_payment_mode`` v18 still depends on ``account_payment_partner``
(removed by the bank-payment renaming) and uses the obsolete
``account.payment.mode`` model; no v18 replacement provides contract
integration, and only 2 contracts carried a ``payment_mode_id``.

Must run BEFORE the bank-payment renaming and BEFORE OpenUpgrade's
``button_upgrade()`` which would otherwise crash on the missing
dependency.

The module is DELETED (module row + ``ir_model_data`` + dependencies)
rather than marked 'to remove', because Odoo's "Transient module states
were reset" in ``load_modules()`` converts 'to remove' -> 'installed',
making ``button_upgrade()`` re-parse the missing
``account_payment_partner`` dependency and abort the registry load. The
orphaned ``base.module_contract_payment_mode`` xmlid is renamed so
``update_list()`` rediscovers the physical addon as a fresh uninstalled
module that ``button_upgrade()`` never touches.
2026-08-07 10:35:59 +02:00
Stéphan Sainléger
bc3907e1d8 [FIX] l10n_fr_account: recreate missing property-account xml-ids in 18.0
The core script ``l10n_fr_account/migrations/2.1/end-migrate_update_taxes.py``
calls ``account.chart.template.try_loading('fr', company)``. During
``_post_load_data``, Odoo 18 resolves the French template's default accounts via
``self.ref()`` WITHOUT ``raise_if_not_found=False`` (chart_template.py:711/714
and the ``_get_property_accounts`` loop at :746). If any expected
``account.<company>_<key>`` xml-id is missing, it raises
``ValueError: External ID not found`` and aborts the registry load.

This happens when a database customized its chart of accounts: the generic PCG
account was deleted (e.g. 607000) or recreated without its xml-id (e.g. 707000).

Add a generic ORM ``post-migration`` script that, for every company with a
``chart_template``, reads the expected account xml-ids from the template API
(``_get_property_accounts`` / ``_get_chart_template_data`` /
``_get_account_account``) and recreates any missing ``account.<company>_<key>``
``ir.model.data`` pointing to the best matching account: exact code, else the
company account sharing the longest common code prefix, else a non-blocking
warning. It runs at stage ``post`` (before the native ``end`` script) and only
creates missing xml-ids — no account is modified. Idempotent, generic across
all migrated FR databases.

Remove the previous hardcoded 607/707 SQL block from
``versions/18.0/pre_upgrade.sh`` now superseded by this script.
2026-07-22 16:14:36 +02:00
Stéphan Sainléger
a3bd1bbbe8 [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``.
2026-07-14 00:24:54 +02:00
Stéphan Sainléger
a2450faf93 [IMP] add hr_expense_report_merge_attachment in "merged in core" modules in 18.0 2026-07-07 22:24:17 +02:00
Stéphan Sainléger
3b81052ca6 [IMP] delete res.settings views in 18.0 pre-update to rebuild them latter 2026-07-07 22:24:17 +02:00
Stéphan Sainléger
231ec1e9b7 [IMP] manage the sequence issues in stock picking and pos orders in v18 post-upgrade 2026-07-07 22:24:17 +02:00
Stéphan Sainléger
1c88a2d6af [IMP] add Odoo addons known changes 2026-07-07 22:24:17 +02:00
Stéphan Sainléger
4594d5971c [NEW] add detection of obsolete, Odoo core integrated or renamed addons 2026-07-07 22:24:17 +02:00
Stéphan Sainléger
bf022605d4 [IMP] add migrations script to use bank-payment-alternative addons in 18.0 2026-07-07 22:21:42 +02:00
Stéphan Sainléger
ee27536011 [FIX] use relative path for compose to avoid 0k dev-pack IOError
The 0k dev-pack's compose script doesn't handle absolute paths correctly.
It passes HOST_COMPOSE_YML_FILE to the container, which tries to open
it directly instead of using the mounted path.

Add run_compose() wrapper that changes to PROJECT_ROOT before calling
compose with a relative path, ensuring consistent behavior regardless
of the current working directory.
2026-02-03 17:15:20 +01:00
Stéphan Sainléger
8d2b151a85 [IMP] update all script paths for new directory structure
Update all path references to match the new directory layout:

upgrade.sh:
  - ./prepare_db.sh -> ${SCRIPT_DIR}/scripts/prepare_db.sh
  - ./finalize_db.sh -> ${SCRIPT_DIR}/scripts/finalize_db.sh
  - ${SCRIPT_DIR}/${version}.0/ -> ${SCRIPT_DIR}/versions/${version}.0/

scripts/prepare_db.sh:
  - pre_migration_view_checking.py -> ${SCRIPT_DIR}/lib/python/check_views.py

scripts/finalize_db.sh:
  - post_migration_fix_duplicated_views.py -> ${SCRIPT_DIR}/lib/python/fix_duplicated_views.py
  - post_migration_cleanup_obsolete_modules.py -> ${SCRIPT_DIR}/lib/python/cleanup_modules.py

versions/*/upgrade.sh:
  - ../compose.yml -> ../../config/compose.yml
2026-02-02 22:11:15 +01:00
Stéphan Sainléger
245ddcc3f9 [IMP] reorganize project directory structure
Restructure the project for better organization and maintainability:

New structure:
  ./upgrade.sh              - Main entry point (unchanged)
  ./lib/common.sh           - Shared bash functions
  ./lib/python/             - Python utility scripts
  ./scripts/                - Workflow scripts (prepare_db, finalize_db)
  ./config/                 - Configuration files (compose.yml)
  ./versions/{13..18}.0/    - Version-specific migration scripts

File renames:
  - pre_migration_view_checking.py -> lib/python/check_views.py
  - post_migration_fix_duplicated_views.py -> lib/python/fix_duplicated_views.py
  - post_migration_cleanup_obsolete_modules.py -> lib/python/cleanup_modules.py

Benefits:
  - Single entry point visible at root level
  - Clear separation between shared code, scripts, and config
  - Shorter, cleaner Python script names (context given by caller)
  - Easier navigation and maintenance
2026-02-02 22:10:01 +01:00