diff --git a/.github/workflows/documentation-commit.yml b/.github/workflows/documentation-commit.yml new file mode 100644 index 000000000000..8b69cde83dcf --- /dev/null +++ b/.github/workflows/documentation-commit.yml @@ -0,0 +1,67 @@ +# On each push in 19.0 branch, +# AND if the coverage file changed, +# build documentation branch and commit the changes +# so that the changes are visible on the website +# https://oca.github.io/OpenUpgrade/ + +name: Build and commit documentation + +on: + push: + paths: ["docsource/modules180-190.rst"] + +jobs: + documentation-commit: + runs-on: ubuntu-latest + steps: + - name: Check out OpenUpgrade Documentation + uses: actions/checkout@v2 + with: + ref: "documentation" + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Check out Odoo + uses: actions/checkout@v2 + with: + repository: odoo/odoo + ref: "19.0" + fetch-depth: 1 + path: odoo + - name: Configuration + run: | + sudo apt update + sudo apt install \ + expect \ + expect-dev \ + libevent-dev \ + libldap2-dev \ + libsasl2-dev \ + libxml2-dev \ + libxslt1-dev \ + nodejs \ + python3-lxml \ + python3-passlib \ + python3-psycopg2 \ + python3-serial \ + python3-simplejson \ + python3-werkzeug \ + python3-yaml \ + unixodbc-dev + - name: Requirements Installation + run: | + sed -i -E "s/(gevent==)21\.8\.0( ; sys_platform != 'win32' and python_version == '3.10')/\122.10.2\2/;s/(greenlet==)1.1.2( ; sys_platform != 'win32' and python_version == '3.10')/\12.0.2\2/" odoo/requirements.txt + pip install -q -r odoo/requirements.txt + pip install -r ./requirements.txt + - name: OpenUpgrade Docs + run: | + # try to build the documentation + sh ./build_openupgrade_docs + - name: Commit changes + uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 #v9 + with: + add: "docs" + default_author: github_actions + message: "[UPD] HTML documentation" diff --git a/.github/workflows/generate-analysis-cron.yml b/.github/workflows/generate-analysis-cron.yml new file mode 100644 index 000000000000..5c3c10c00565 --- /dev/null +++ b/.github/workflows/generate-analysis-cron.yml @@ -0,0 +1,18 @@ +name: Generate analysis files - cron and push + +on: + push: + # when module merges are added to apriori, this + # might cause changes in the analysis + paths: ["openupgrade_scripts/apriori.py"] + schedule: + # every monday at 04:00 + - cron: "0 4 * * 1" + +jobs: + generate-analysis18: + if: github.repository == 'OCA/OpenUpgrade' && (github.event_name == 'schedule' || github.ref_name == '18.0') + uses: ./.github/workflows/generate-analysis.yml + with: + from_version: "17.0" + to_version: "18.0" diff --git a/.github/workflows/generate-analysis.yml b/.github/workflows/generate-analysis.yml new file mode 100644 index 000000000000..00268e00c571 --- /dev/null +++ b/.github/workflows/generate-analysis.yml @@ -0,0 +1,226 @@ +name: Generate analysis files + +on: + workflow_call: + inputs: + from_version: + required: true + type: string + from_version_requirements: + default: 'gevent==22.10.2 greenlet==2.0.2' + type: string + from_version_requirements_sed: + default: '/^gevent\>/d; /^greenlet\>/d' + type: string + to_version: + required: true + type: string + to_version_requirements: + default: 'gevent==22.10.2 greenlet==2.0.2' + type: string + to_version_requirements_sed: + default: '/^gevent\>/d; /^greenlet\>/d' + type: string + python_version: + default: "3.10" + type: string + postgres_version: + default: "14" + type: string + +jobs: + generate-analysis: + name: Generate analysis ${{ inputs.to_version }} + runs-on: ubuntu-latest + env: + PGHOST: "localhost" + PGPASSWORD: "odoo" + PGUSER: "odoo" + FROM_VERSION: "${{ inputs.from_version }}" + TO_VERSION: "${{ inputs.to_version }}" + services: + postgres: + image: postgres:${{ inputs.postgres_version }} + env: + POSTGRES_USER: odoo + POSTGRES_PASSWORD: odoo + ports: + - 5432:5432 + steps: + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "${{ inputs.python_version }}" + - name: Install required packages + run: | + sudo apt update + sudo apt install \ + expect \ + expect-dev \ + libevent-dev \ + libldap2-dev \ + libsasl2-dev \ + libxml2-dev \ + libxslt1-dev \ + nodejs \ + python3-lxml \ + python3-passlib \ + python3-psycopg2 \ + python3-serial \ + python3-simplejson \ + python3-werkzeug \ + python3-yaml \ + unixodbc-dev + - name: Checkout previous OpenUpgrade + uses: actions/checkout@v4 + with: + ref: "${{ env.FROM_VERSION }}" + path: openupgrade-${{ env.FROM_VERSION }} + - name: Checkout OpenUpgrade from current branch + if: github.event_name != 'schedule' && startsWith(github.ref_name, env.TO_VERSION) + uses: actions/checkout@v4 + with: + path: openupgrade-${{ env.TO_VERSION }} + - name: Checkout current OpenUpgrade + if: github.event_name == 'schedule' || !startsWith(github.ref_name, env.TO_VERSION) + uses: actions/checkout@v4 + with: + ref: "${{ env.TO_VERSION }}" + path: openupgrade-${{ env.TO_VERSION }} + - name: Install previous Odoo + run: | + wget -q -O- https://github.com/oca/ocb/archive/refs/heads/$FROM_VERSION.tar.gz | tar -xz + wget -q -O- https://github.com/oca/server-tools/archive/refs/heads/$FROM_VERSION.tar.gz | tar -xz + python -mvenv env-$FROM_VERSION + . env-$FROM_VERSION/bin/activate + pip install ${{ inputs.from_version_requirements }} + sed -iE '${{ inputs.from_version_requirements_sed }}' OCB-$FROM_VERSION/requirements.txt + pip install -r OCB-$FROM_VERSION/requirements.txt + pip install ./OCB-$FROM_VERSION + pip install -r server-tools-$FROM_VERSION/requirements.txt + pip install -r openupgrade-$FROM_VERSION/requirements.txt + # this is for l10n_eg_edi_eta which crashes without it + pip install asn1crypto + odoo -s -c odoo-$FROM_VERSION.cfg --addons-path server-tools-$FROM_VERSION,openupgrade-$FROM_VERSION --stop-after-init + - name: Install current Odoo + run: | + wget -q -O- https://github.com/oca/ocb/archive/refs/heads/$TO_VERSION.tar.gz | tar -xz + wget -q -O- https://github.com/oca/server-tools/archive/refs/heads/$TO_VERSION.tar.gz | tar -xz + python -mvenv env-$TO_VERSION + . env-$TO_VERSION/bin/activate + pip install ${{ inputs.to_version_requirements }} + sed -iE '${{ inputs.to_version_requirements_sed }}' OCB-$TO_VERSION/requirements.txt + pip install -r OCB-$TO_VERSION/requirements.txt + pip install ./OCB-$TO_VERSION + pip install -r server-tools-$TO_VERSION/requirements.txt + pip install -r openupgrade-$TO_VERSION/requirements.txt + # this is for l10n_eg_edi_eta which crashes without it + pip install asn1crypto + odoo -s -c odoo-$TO_VERSION.cfg --addons-path server-tools-$TO_VERSION,openupgrade-$TO_VERSION --stop-after-init + - name: Create previous Odoo database + env: + ODOO: env-${{ env.FROM_VERSION }}/bin/odoo -c odoo-${{ env.FROM_VERSION }}.cfg -d ${{ env.FROM_VERSION }} + ODOO_SHELL: env-${{ env.FROM_VERSION }}/bin/odoo shell -c odoo-${{ env.FROM_VERSION }}.cfg -d ${{ env.FROM_VERSION }} + run: | + $ODOO --without-demo=all -i upgrade_analysis --stop-after-init + $ODOO_SHELL < "$PR_BODY" + + for module in $( + git -C $OPENUPGRADE_DIR status --short | awk '{print $2}' | awk -F/ '{print $3}' | sort -u + ); do + if grep -qE "\<$module\>.*\<((Done)|(No))" $OPENUPGRADE_DIR/docsource/modules*; then + echo Done module $module was updated + echo "- $module" >> $PR_BODY + else + echo $module is not done yet + fi + done + + if ! grep -q - $PR_BODY; then + echo None >> $PR_BODY + fi + + echo "body-file=$PR_BODY" >> "$GITHUB_OUTPUT" + - name: Get number of milestone + id: get_milestone + run: | + echo "number=$( + wget -qO- https://api.github.com/repos/${{ github.repository }}/milestones|jq '.[] | select(.title=="${{ env.TO_VERSION }}") .number' + )" >> "$GITHUB_OUTPUT" + - name: Create PR + uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e #v7 + with: + base: "${{ env.TO_VERSION }}" + body-path: "${{ steps.generate_body.outputs.body-file }}" + branch: "${{ env.TO_VERSION }}-update-analysis-bot" + commit-message: "[IMP] Update analysis files" + delete-branch: true + milestone: "${{ steps.get_milestone.outputs.number }}" + path: "openupgrade-${{ env.TO_VERSION }}" + title: "[${{ env.TO_VERSION }}][IMP] Update analysis files" diff --git a/.github/workflows/test-migration.yml b/.github/workflows/test-migration.yml new file mode 100644 index 000000000000..9402b8527709 --- /dev/null +++ b/.github/workflows/test-migration.yml @@ -0,0 +1,172 @@ +# This workflow will install Python dependencies, run tests and lint with a +# single version of Python. For more information see: +# https://help.github.com/actions/language-and-framework-guides\ +# /using-python-with-github-actions + +name: Test OpenUpgrade migration + +on: + pull_request: + branches: + - "19.0*" + push: + branches: + - "19.0" + - "19.0-ocabot-*" + +jobs: + test: + runs-on: ubuntu-22.04 + env: + DB: "openupgrade" + DB_HOST: "localhost" + DB_PASSWORD: "odoo" + DB_PORT: 5432 + DB_USERNAME: "odoo" + DOWNLOADS: https://github.com/${{github.repository}}/releases/download/databases + ODOO: "./odoo/odoo-bin" + PGHOST: "localhost" + PGPASSWORD: "odoo" + PGUSER: "odoo" + OPENUPGRADE_USE_DEMO: "yes" + services: + postgres: + image: postgres:14.0 + env: + POSTGRES_USER: odoo + POSTGRES_PASSWORD: odoo + POSTGRES_DB: odoo + ports: + - 5432:5432 + steps: + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Sleep for 10 seconds + run: sleep 10s + - name: DB Creation + run: createdb $DB + - name: DB Restore + run: | + wget -q -O- $DOWNLOADS/18.0.psql | pg_restore -d $DB --no-owner + psql $DB -c "UPDATE ir_module_module SET demo=False" + - name: Check out Odoo + uses: actions/checkout@v4 + with: + repository: odoo/odoo + ref: "19.0" + fetch-depth: 1 + path: odoo + - name: Check out previous Odoo + uses: actions/checkout@v4 + with: + repository: odoo/odoo + ref: "18.0" + fetch-depth: 1 + path: odoo-old + - name: Check out OpenUpgrade + uses: actions/checkout@v4 + with: + path: openupgrade + - name: Configuration + run: | + sudo apt update + sudo apt install \ + expect \ + expect-dev \ + libevent-dev \ + libldap2-dev \ + libsasl2-dev \ + libxml2-dev \ + libxslt1-dev \ + nodejs \ + python3-lxml \ + python3-passlib \ + python3-psycopg2 \ + python3-serial \ + python3-simplejson \ + python3-werkzeug \ + python3-yaml \ + unixodbc-dev + - name: Requirements Installation + run: | + sed -i -E "s/(gevent==)21\.8\.0( ; sys_platform != 'win32' and python_version == '3.10')/\122.10.2\2/;s/(greenlet==)1.1.2( ; sys_platform != 'win32' and python_version == '3.10')/\12.0.2\2/" odoo/requirements.txt + sed -i -E "s/(^cbor2==)5\.4\.2/\15.6.2/" odoo/requirements.txt + pip install -q -r odoo/requirements.txt + pip install -r ./openupgrade/requirements.txt + pip install -U git+https://github.com/oca/openupgradelib + # this is for v16 l10n_eg_edi_eta which crashes without it + pip install asn1crypto + pip install coverage + # this is for account_peppol + pip install phonenumbers + - name: Test data + run: | + if test -n "$(ls openupgrade/openupgrade_scripts/scripts/*/tests/data*.py 2> /dev/null)"; then + for snippet in openupgrade/openupgrade_scripts/scripts/*/tests/data*.py; do + odoo-old/odoo-bin shell -d $DB < $snippet + done + fi + - name: OpenUpgrade test + id: run_migration + run: | + # select modules and perform the upgrade + MODULES_OLD=$(\ + sed -n '/^+========/,$p' \ + openupgrade/docsource/modules180-190.rst \ + | grep "Done\|Partial\|Nothing" \ + | grep -v "theme_" \ + | sed -rn 's/((^\| *\|del\| *)|^\| *)([0-9a-z_]*)[ \|].*/\3/g p' \ + | sed '/^\s*$/d' \ + | paste -d, -s) + MODULES_NEW=$(\ + sed -n '/^+========/,$p' \ + openupgrade/docsource/modules180-190.rst \ + | grep "Done\|Partial\|Nothing" \ + | grep -v "theme_" \ + | sed -rn 's/((^\| *\|new\| *)|^\| *)([0-9a-z_]*)[ \|].*/\3/g p' \ + | sed '/^\s*$/d' \ + | paste -d, -s) + echo "modules_old=$MODULES_OLD" >> $GITHUB_OUTPUT + echo "modules_new=$MODULES_NEW" >> $GITHUB_OUTPUT + if [ -z "$MODULES_NEW" ]; then + echo "No modules to test yet" + exit + fi + REQUEST="update ir_module_module set state='uninstalled' \ + where name not in ('$(echo $MODULES_OLD | sed -e "s/,/','/g")')" + echo Set the modules as not installable if they are not in the following list : $MODULES_OLD + echo Running $REQUEST + psql $DB -c "$REQUEST" + ADDONS_PATHS="\ + $GITHUB_WORKSPACE/odoo/addons \ + $GITHUB_WORKSPACE/odoo/odoo/addons \ + $GITHUB_WORKSPACE/openupgrade" + echo Execution of Openupgrade with the update of the following modules : $MODULES_NEW + # Silence redundant logs from unlinking records (1 line is enough) + # to prevent log overflow + coverage run \ + --source=$GITHUB_WORKSPACE/openupgrade/openupgrade_scripts/scripts \ + $ODOO \ + --addons-path=`echo $ADDONS_PATHS | awk -v OFS="," '$1=$1'` \ + --database=$DB \ + --db_host=$DB_HOST \ + --db_password=$DB_PASSWORD \ + --db_port=$DB_PORT \ + --db_user=$DB_USERNAME \ + --load=base,web,openupgrade_framework \ + --test-enable \ + --test-tags openupgrade \ + --log-handler odoo.models.unlink:WARNING \ + --stop-after-init \ + --without-demo=$MODULES_NEW \ + --update=$MODULES_NEW + - name: Generate coverage.xml + if: ${{ steps.run_migration.outputs.modules_new != '' }} + run: coverage xml + - uses: codecov/codecov-action@v4 + if: ${{ steps.run_migration.outputs.modules_new != '' }} + with: + files: coverage.xml + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000000..22a8861c737d --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +openupgrade_scripts/scripts/*/*/noupdate_changes*.xml +docsource/*.rst +docs diff --git a/openupgrade_framework/README.rst b/openupgrade_framework/README.rst new file mode 100644 index 000000000000..17277fb6cec1 --- /dev/null +++ b/openupgrade_framework/README.rst @@ -0,0 +1,214 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +===================== +Openupgrade Framework +===================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:cadb60113e07a02008a69c0d3e3fe2e0a8ca46545ad75dfe579711c42cb367b3 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2FOpenUpgrade-lightgray.png?logo=github + :target: https://github.com/OCA/OpenUpgrade/tree/19.0/openupgrade_framework + :alt: OCA/OpenUpgrade +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/OpenUpgrade-19-0/OpenUpgrade-19-0-openupgrade_framework + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/OpenUpgrade&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module is a technical module that contains a number of +monkeypatches to improve the behaviour of Odoo when migrating your +database using the OpenUpgrade migration scripts: + +- Prevent dropping columns or tables in the database when fields or + models are obsoleted in the Odoo data model of the target release. + After the migration, you can review and delete unused database tables + and columns using database_cleanup. See + https://odoo-community.org/shop/product/database-cleanup-918 +- When data records are deleted during the migration (such as views or + other system records), this is done in a secure mode. If the deletion + fails because of some unforeseen dependency, the deletion will be + cancelled and a message is logged, after which the migration + continues. +- Prevent a number of log messages that do not apply when using + OpenUpgrade. +- Suppress log messages about failed view validation, which are to be + expected during a migration. +- Run migration scripts for modules that are installed as new + dependencies of upgraded modules (when there are such scripts for + those particular modules) +- Production databases generated with demo data, will be transformed to + non-demo ones. If you want to avoid that, you have to pass through + the environment variable OPENUPGRADE_USE_DEMO, the value "yes". + +For detailed documentation see: + +- https://github.com/OCA/OpenUpgrade/ +- https://oca.github.io/OpenUpgrade + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +This module does not need to be installed on a database. It simply needs +to be available via your ``addons-path``. + +Configuration +============= + +- call your odoo instance with the option + ``--load=base,web,openupgrade_framework`` + +or + +- add the key to your configuration file: + +.. code:: shell + + [options] + server_wide_modules = web,openupgrade_framework + +When you load the module in either way of these ways, and you have the +openupgrade_scripts module in your addons path available, the +--upgrade-path option of Odoo will be set automatically to the location +of the OpenUpgrade migration scripts. + +Development +=========== + +The odoo_patch folder contains python files in a tree that mimicks the +folder tree of the Odoo project. It contains a number of monkey patches +to improve the migration of an Odoo database between two major versions. + +So far, we are able to make everything work without overwriting large +blocks of code, but if larger patches need to be added, please use the +method described below: + +To see the patches added, you can use ``meld`` tools: + +``meld PATH_TO_ODOO_FOLDER/odoo/ PATH_TO_OPENUPGRADE_FRAMEWORK_MODULE/odoo_patch`` + +To make more easy the diff analysis : + +- Make sure the python files has the same path as the original one. +- Keep the same indentation as the original file. (using ``if True:`` + if required) +- Add the following two lines at the beginning of your file, to avoid + flake8 / pylint errors + +.. code:: python + + # flake8: noqa + # pylint: skip-file + +- When you want to change the code. add the following tags: + +For an addition: + +.. code:: python + + # + some code... + # + +For a change: + +.. code:: python + + # + some code... + # + +For a removal: + +.. code:: python + + # + # Comment the code, instead of removing it. + # + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Therp BV +* Opener B.V. +* GRAP +* Hunki Enterprises BV + +Contributors +------------ + +- Stefan Rijnhart +- Sylvain LE GAL + +Other credits +------------- + +Many developers have contributed to the OpenUpgrade framework in its +previous incarnation. Their original contributions may no longer needed, +or they are no longer recognizable in their current form but OpenUpgrade +would not have existed at this point without them. + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px + :target: https://github.com/legalsylvain + :alt: legalsylvain +.. |maintainer-StefanRijnhart| image:: https://github.com/StefanRijnhart.png?size=40px + :target: https://github.com/StefanRijnhart + :alt: StefanRijnhart +.. |maintainer-hbrunn| image:: https://github.com/hbrunn.png?size=40px + :target: https://github.com/hbrunn + :alt: hbrunn + +Current `maintainers `__: + +|maintainer-legalsylvain| |maintainer-StefanRijnhart| |maintainer-hbrunn| + +This module is part of the `OCA/OpenUpgrade `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/openupgrade_framework/__init__.py b/openupgrade_framework/__init__.py new file mode 100644 index 000000000000..97a704fd9e63 --- /dev/null +++ b/openupgrade_framework/__init__.py @@ -0,0 +1,33 @@ +import logging +import os + +from odoo.modules import get_module_path +from odoo.tools import config + +from . import odoo_patch + +if not config.get("upgrade_path"): + path = get_module_path("openupgrade_scripts", display_warning=False) + if path and os.path.isdir(os.path.join(path, "scripts")): + logging.getLogger(__name__).info( + "Setting upgrade_path to the scripts directory inside the module " + "location of openupgrade_scripts" + ) + config["upgrade_path"] = os.path.join(path, "scripts") + + +def openupgrade_test(cls): + """ + Set attributes on a test class necessary for the test framework + Use as decorator on test classes in openupgrade_scripts/scripts/*/tests/test_*.py + """ + tags = getattr(cls, "test_tags", None) or set() + if "openupgrade" not in tags: + tags.add("openupgrade") + if not any(t.endswith("_install") for t in tags): + tags.add("at_install") + cls.test_tags = tags + cls.test_module = cls.__module__.split(".")[2] + cls.test_class = cls.__name__ + cls.test_sequence = 0 + return cls diff --git a/openupgrade_framework/__manifest__.py b/openupgrade_framework/__manifest__.py new file mode 100644 index 000000000000..491fb07402f6 --- /dev/null +++ b/openupgrade_framework/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "Openupgrade Framework", + "summary": """Module to integrate in the server_wide_modules + option to make upgrades between two major revisions.""", + "author": "Odoo Community Association (OCA), Therp BV, Opener B.V., GRAP, " + "Hunki Enterprises BV", + "maintainers": ["legalsylvain", "StefanRijnhart", "hbrunn"], + "website": "https://github.com/OCA/OpenUpgrade", + "category": "Migration", + "version": "19.0.1.0.0", + "license": "AGPL-3", + "depends": ["base"], + "images": ["static/description/banner.jpg"], + "external_dependencies": {"python": ["openupgradelib"]}, + "installable": True, +} diff --git a/openupgrade_framework/odoo_patch/__init__.py b/openupgrade_framework/odoo_patch/__init__.py new file mode 100644 index 000000000000..3c691cd11703 --- /dev/null +++ b/openupgrade_framework/odoo_patch/__init__.py @@ -0,0 +1 @@ +from . import odoo diff --git a/openupgrade_framework/odoo_patch/odoo/__init__.py b/openupgrade_framework/odoo_patch/odoo/__init__.py new file mode 100644 index 000000000000..18ff659459d2 --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/__init__.py @@ -0,0 +1 @@ +from . import addons, modules, orm diff --git a/openupgrade_framework/odoo_patch/odoo/addons/__init__.py b/openupgrade_framework/odoo_patch/odoo/addons/__init__.py new file mode 100644 index 000000000000..0e44449338cf --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/addons/__init__.py @@ -0,0 +1 @@ +from . import base diff --git a/openupgrade_framework/odoo_patch/odoo/addons/base/__init__.py b/openupgrade_framework/odoo_patch/odoo/addons/base/__init__.py new file mode 100644 index 000000000000..0650744f6bc6 --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/addons/base/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/openupgrade_framework/odoo_patch/odoo/addons/base/models/__init__.py b/openupgrade_framework/odoo_patch/odoo/addons/base/models/__init__.py new file mode 100644 index 000000000000..5ec7e0740f90 --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/addons/base/models/__init__.py @@ -0,0 +1,3 @@ +from . import ir_model +from . import ir_module +from . import ir_ui_view diff --git a/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_model.py b/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_model.py new file mode 100644 index 000000000000..11c1864b2540 --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_model.py @@ -0,0 +1,58 @@ +# Copyright Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from openupgradelib import openupgrade + +from odoo import models + +from odoo.addons.base.models.ir_model import ( + IrModel, + IrModelFields, + IrModelRelation, +) + + +def _drop_table(self): + """Never drop tables""" + for model in self: + if self.env.get(model.model) is not None: + openupgrade.message( + self.env.cr, + "Unknown", + False, + False, + "Not dropping the table or view of model %s", + model.model, + ) + + +IrModel._drop_table = _drop_table + + +def _drop_column(self): + """Never drop columns""" + for field in self: + if field.name in models.MAGIC_COLUMNS: + continue + openupgrade.message( + self.env.cr, + "Unknown", + False, + False, + "Not dropping the column of field %s of model %s", + field.name, + field.model, + ) + continue + + +IrModelFields._drop_column = _drop_column + + +def _module_data_uninstall(self): + """Don't delete many2many relation tables. Only unlink the + ir.model.relation record itself. + """ + self.unlink() + + +IrModelRelation._module_data_uninstall = _module_data_uninstall diff --git a/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_module.py b/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_module.py new file mode 100644 index 000000000000..b71e0f78534f --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_module.py @@ -0,0 +1,50 @@ +# Copyright Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api + +from odoo.addons.base.models.ir_module import IrModuleModule + + +@api.model +def update_list(self): + """ + Mark auto_install modules as to install if all their dependencies are some kind of + installed. + Ignore localization modules that are set to auto_install + """ + result = IrModuleModule.update_list._original_method(self) + new_auto_install_modules = self.browse([]) + for module in self.env["ir.module.module"].search( + [ + ("auto_install", "=", True), + ("state", "=", "uninstalled"), + ("name", "not like", ("l10n_%")), + ] + ): + if all( + state in ("to upgrade", "to install", "installed") + for state in module.dependencies_id.mapped("state") + ): + new_auto_install_modules |= module + if new_auto_install_modules: + new_auto_install_modules.button_install() + return result + + +def check_external_dependencies(self, module_name, newstate="to install"): + try: + IrModuleModule.check_external_dependencies._original_method( + self, module_name, newstate=newstate + ) + except AttributeError: # pylint: disable=except-pass + # this happens when a module is installed that doesn't exist in the new version + pass + + +update_list._original_method = IrModuleModule.update_list +IrModuleModule.update_list = update_list +check_external_dependencies._original_method = ( + IrModuleModule.check_external_dependencies +) +IrModuleModule.check_external_dependencies = check_external_dependencies diff --git a/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_ui_view.py b/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_ui_view.py new file mode 100644 index 000000000000..5042778ee042 --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_ui_view.py @@ -0,0 +1,96 @@ +# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo) +# Copyright Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import logging + +from odoo import api +from odoo.exceptions import ValidationError +from odoo.modules.module import get_resource_from_path +from odoo.tools import mute_logger + +from odoo.addons.base.models.ir_ui_view import IrUiView + +_logger = logging.getLogger(__name__) + + +@api.constrains("arch_db") +def _check_xml(self): + """Don't raise or log exceptions in view validation unless explicitely + requested. Mute warnings about views which are common during migration.""" + with mute_logger("odoo.addons.base.models.ir_ui_view"): + try: + return IrUiView._check_xml._original_method(self) + except ValidationError as e: + _logger.warning( + "Can't render custom view %s for model %s. " + "Assuming you are migrating between major versions of Odoo. " + "Please review the view contents manually after the migration.\n" + "Error: %s", + self.xml_id, + self.model, + e, + ) + + +def _raise_view_error( + self, message, node=None, *, from_exception=None, from_traceback=None +): + """Don't raise or log exceptions in view validation unless explicitely + requested + """ + raise_exception = self.env.context.get("raise_view_error") + to_mute = "odoo.addons.base.models.ir_ui_view" if raise_exception else "not_muted" + with mute_logger(to_mute): + try: + return IrUiView._raise_view_error._original_method( + self, + message, + node=node, + from_exception=from_exception, + from_traceback=from_traceback, + ) + except ValueError as e: + _logger.warning( + "Can't render custom view %s for model %s. " + "Assuming you are migrating between major versions of Odoo. " + "Please review the view contents manually after the migration.\n" + "Error: %s", + self.xml_id, + self.model, + e, + ) + + +def _check_field_paths(self, node, field_paths, model_name, use): + """Ignore UnboundLocalError when we squelched the raise about missing fields""" + try: + return IrUiView._check_field_paths._original_method( + self, node, field_paths, model_name, use + ) + except UnboundLocalError: # pylint: disable=except-pass + pass + + +def _inverse_arch(self): + """ + Remove install_filename from context if it's from openupgrade_scripts. + Without this, arch_fs will point to openupgrade_scripts' file which most likely + won't exist when the migrated database is deployed, which breaks resetting views + """ + if "install_filename" in self.env.context: + path_info = get_resource_from_path(self.env.context["install_filename"]) + if path_info and path_info[0] == "openupgrade_scripts": + self = self.with_context( # pylint: disable=context-overridden + {k: v for k, v in self.env.context.items() if k != "install_filename"} + ) + return _inverse_arch._original_method(self) + + +_check_xml._original_method = IrUiView._check_xml +IrUiView._check_xml = _check_xml +_raise_view_error._original_method = IrUiView._raise_view_error +IrUiView._raise_view_error = _raise_view_error +_check_field_paths._original_method = IrUiView._check_field_paths +IrUiView._check_field_paths = _check_field_paths +_inverse_arch._original_method = IrUiView._inverse_arch +IrUiView._inverse_arch = _inverse_arch diff --git a/openupgrade_framework/odoo_patch/odoo/modules/__init__.py b/openupgrade_framework/odoo_patch/odoo/modules/__init__.py new file mode 100644 index 000000000000..e060fc2ed96b --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/modules/__init__.py @@ -0,0 +1 @@ +from . import module_graph, loading, migration diff --git a/openupgrade_framework/odoo_patch/odoo/modules/loading.py b/openupgrade_framework/odoo_patch/odoo/modules/loading.py new file mode 100644 index 000000000000..4715de5ea370 --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/modules/loading.py @@ -0,0 +1,18 @@ +# Copyright Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import odoo.modules.loading + + +def load_module_graph(env, graph, *args, **kwargs): + """ + Force run pre-migration scripts for modules being installed + """ + env.registry._force_upgrade_scripts.update(set(package.name for package in graph)) + return odoo.modules.loading.load_module_graph._original_method( + env, graph, *args, **kwargs + ) + + +load_module_graph._original_method = odoo.modules.loading.load_module_graph +odoo.modules.loading.load_module_graph = load_module_graph diff --git a/openupgrade_framework/odoo_patch/odoo/modules/migration.py b/openupgrade_framework/odoo_patch/odoo/modules/migration.py new file mode 100644 index 000000000000..fdc6f09eda1b --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/modules/migration.py @@ -0,0 +1,16 @@ +# Copyright Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo.modules.migration import MigrationManager + + +def _get_files(self): + """Turns out Odoo SA sometimes add migration scripts that interfere with + OpenUpgrade. Those we filter out here""" + MigrationManager._get_files._original_method(self) + to_exclude = [("analytic", "1.2")] + for addon, version in to_exclude: + self.migrations.get(addon, {}).get("module", {}).pop(version, None) + + +_get_files._original_method = MigrationManager._get_files +MigrationManager._get_files = _get_files diff --git a/openupgrade_framework/odoo_patch/odoo/modules/module_graph.py b/openupgrade_framework/odoo_patch/odoo/modules/module_graph.py new file mode 100644 index 000000000000..dbe2d2a73f5f --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/modules/module_graph.py @@ -0,0 +1,35 @@ +# Copyright Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import os + +import odoo +from odoo.modules.module_graph import ModuleGraph + + +def _update_from_database(self, *args, **kwargs) -> None: + """Prevent reloading of demo data from the new version on major upgrade""" + ModuleGraph._update_from_database._original_method(self, *args, **kwargs) + + # v19-specific: ir.model.fields#translate has changed semantics, untranslated fields + # need to be set to null instead of false. and as this is read before any upgrade + # scripts run, we do it here. the statement is a bit clunky because it has to work + # before and after the translate column is converted from boolean to varchar + self._cr.execute( + "UPDATE ir_model_fields SET translate=NULL where translate::varchar='false'" + ) + + if os.environ.get("OPENUPGRADE_USE_DEMO", "") == "yes": + return + + if ( + "base" in self._modules + and self._modules["base"].demo + and self._modules["base"].installed_version < odoo.release.major_version + ): + self._cr.execute("UPDATE ir_module_module SET demo = false") + for module in self._modules.values(): + module.demo = False + + +_update_from_database._original_method = ModuleGraph._update_from_database +ModuleGraph._update_from_database = _update_from_database diff --git a/openupgrade_framework/odoo_patch/odoo/orm/__init__.py b/openupgrade_framework/odoo_patch/odoo/orm/__init__.py new file mode 100644 index 000000000000..0650744f6bc6 --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/orm/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/openupgrade_framework/odoo_patch/odoo/orm/models.py b/openupgrade_framework/odoo_patch/odoo/orm/models.py new file mode 100644 index 000000000000..641043d49b69 --- /dev/null +++ b/openupgrade_framework/odoo_patch/odoo/orm/models.py @@ -0,0 +1,42 @@ +# Copyright Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import logging +from uuid import uuid4 + +from odoo.models import BaseModel + +from odoo.addons.base.models.ir_model import MODULE_UNINSTALL_FLAG + +_logger = logging.getLogger(__name__) + + +def unlink(self): + """Don't break on unlink of obsolete records + when called from ir.model::_process_end() + + This only adapts the base unlink method. If overrides of this method + on individual models give problems, add patches for those as well. + """ + if not self.env.context.get(MODULE_UNINSTALL_FLAG): + return BaseModel.unlink._original_method(self) + savepoint = str(uuid4) + try: + self.env.cr.execute( # pylint: disable=sql-injection + f'SAVEPOINT "{savepoint}"' + ) + return BaseModel.unlink._original_method(self) + except Exception as e: + self.env.cr.execute( # pylint: disable=sql-injection + f'ROLLBACK TO SAVEPOINT "{savepoint}"' + ) + _logger.warning( + "Could not delete obsolete record with ids %s of model %s: %s", + self.ids, + self._name, + e, + ) + return False + + +unlink._original_method = BaseModel.unlink +BaseModel.unlink = unlink diff --git a/openupgrade_framework/pyproject.toml b/openupgrade_framework/pyproject.toml new file mode 100644 index 000000000000..4231d0cccb3d --- /dev/null +++ b/openupgrade_framework/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/openupgrade_framework/readme/CONFIGURE.md b/openupgrade_framework/readme/CONFIGURE.md new file mode 100644 index 000000000000..13ef1e5b0946 --- /dev/null +++ b/openupgrade_framework/readme/CONFIGURE.md @@ -0,0 +1,16 @@ +- call your odoo instance with the option + `--load=base,web,openupgrade_framework` + +or + +- add the key to your configuration file: + +``` shell +[options] +server_wide_modules = web,openupgrade_framework +``` + +When you load the module in either way of these ways, and you have the +openupgrade_scripts module in your addons path available, the +--upgrade-path option of Odoo will be set automatically to the location +of the OpenUpgrade migration scripts. diff --git a/openupgrade_framework/readme/CONTRIBUTORS.md b/openupgrade_framework/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..a108409b034c --- /dev/null +++ b/openupgrade_framework/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Stefan Rijnhart \<\> +- Sylvain LE GAL \<\> diff --git a/openupgrade_framework/readme/CREDITS.md b/openupgrade_framework/readme/CREDITS.md new file mode 100644 index 000000000000..fa515612942e --- /dev/null +++ b/openupgrade_framework/readme/CREDITS.md @@ -0,0 +1,4 @@ +Many developers have contributed to the OpenUpgrade framework in its +previous incarnation. Their original contributions may no longer needed, +or they are no longer recognizable in their current form but OpenUpgrade +would not have existed at this point without them. diff --git a/openupgrade_framework/readme/DESCRIPTION.md b/openupgrade_framework/readme/DESCRIPTION.md new file mode 100644 index 000000000000..71cb68ac0b99 --- /dev/null +++ b/openupgrade_framework/readme/DESCRIPTION.md @@ -0,0 +1,29 @@ +This module is a technical module that contains a number of +monkeypatches to improve the behaviour of Odoo when migrating your +database using the OpenUpgrade migration scripts: + +- Prevent dropping columns or tables in the database when fields or + models are obsoleted in the Odoo data model of the target release. + After the migration, you can review and delete unused database tables + and columns using database_cleanup. See + +- When data records are deleted during the migration (such as views or + other system records), this is done in a secure mode. If the deletion + fails because of some unforeseen dependency, the deletion will be + cancelled and a message is logged, after which the migration + continues. +- Prevent a number of log messages that do not apply when using + OpenUpgrade. +- Suppress log messages about failed view validation, which are to be + expected during a migration. +- Run migration scripts for modules that are installed as new + dependencies of upgraded modules (when there are such scripts for + those particular modules) +- Production databases generated with demo data, will be transformed to + non-demo ones. If you want to avoid that, you have to pass through the + environment variable OPENUPGRADE_USE_DEMO, the value "yes". + +For detailed documentation see: + +- +- diff --git a/openupgrade_framework/readme/DEVELOP.md b/openupgrade_framework/readme/DEVELOP.md new file mode 100644 index 000000000000..9d4c548862be --- /dev/null +++ b/openupgrade_framework/readme/DEVELOP.md @@ -0,0 +1,50 @@ +The odoo_patch folder contains python files in a tree that mimicks the +folder tree of the Odoo project. It contains a number of monkey patches +to improve the migration of an Odoo database between two major versions. + +So far, we are able to make everything work without overwriting large +blocks of code, but if larger patches need to be added, please use the +method described below: + +To see the patches added, you can use `meld` tools: + +`meld PATH_TO_ODOO_FOLDER/odoo/ PATH_TO_OPENUPGRADE_FRAMEWORK_MODULE/odoo_patch` + +To make more easy the diff analysis : + +- Make sure the python files has the same path as the original one. +- Keep the same indentation as the original file. (using `if True:` if + required) +- Add the following two lines at the beginning of your file, to avoid + flake8 / pylint errors + +``` python +# flake8: noqa +# pylint: skip-file +``` + +- When you want to change the code. add the following tags: + +For an addition: + +``` python +# +some code... +# +``` + +For a change: + +``` python +# +some code... +# +``` + +For a removal: + +``` python +# +# Comment the code, instead of removing it. +# +``` diff --git a/openupgrade_framework/readme/INSTALL.md b/openupgrade_framework/readme/INSTALL.md new file mode 100644 index 000000000000..471a1d162ce1 --- /dev/null +++ b/openupgrade_framework/readme/INSTALL.md @@ -0,0 +1,2 @@ +This module does not need to be installed on a database. It simply needs +to be available via your `addons-path`. diff --git a/openupgrade_framework/static/description/banner.png b/openupgrade_framework/static/description/banner.png new file mode 100644 index 000000000000..9dd67ec04cf4 Binary files /dev/null and b/openupgrade_framework/static/description/banner.png differ diff --git a/openupgrade_framework/static/description/icon.png b/openupgrade_framework/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/openupgrade_framework/static/description/icon.png differ diff --git a/openupgrade_framework/static/description/index.html b/openupgrade_framework/static/description/index.html new file mode 100644 index 000000000000..ff53fb70f442 --- /dev/null +++ b/openupgrade_framework/static/description/index.html @@ -0,0 +1,543 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Openupgrade Framework

+ +

Beta License: AGPL-3 OCA/OpenUpgrade Translate me on Weblate Try me on Runboat

+

This module is a technical module that contains a number of +monkeypatches to improve the behaviour of Odoo when migrating your +database using the OpenUpgrade migration scripts:

+
    +
  • Prevent dropping columns or tables in the database when fields or +models are obsoleted in the Odoo data model of the target release. +After the migration, you can review and delete unused database tables +and columns using database_cleanup. See +https://odoo-community.org/shop/product/database-cleanup-918
  • +
  • When data records are deleted during the migration (such as views or +other system records), this is done in a secure mode. If the deletion +fails because of some unforeseen dependency, the deletion will be +cancelled and a message is logged, after which the migration +continues.
  • +
  • Prevent a number of log messages that do not apply when using +OpenUpgrade.
  • +
  • Suppress log messages about failed view validation, which are to be +expected during a migration.
  • +
  • Run migration scripts for modules that are installed as new +dependencies of upgraded modules (when there are such scripts for +those particular modules)
  • +
  • Production databases generated with demo data, will be transformed to +non-demo ones. If you want to avoid that, you have to pass through +the environment variable OPENUPGRADE_USE_DEMO, the value “yes”.
  • +
+

For detailed documentation see:

+ +

Table of contents

+ +
+

Installation

+

This module does not need to be installed on a database. It simply needs +to be available via your addons-path.

+
+
+

Configuration

+
    +
  • call your odoo instance with the option +--load=base,web,openupgrade_framework
  • +
+

or

+
    +
  • add the key to your configuration file:
  • +
+
+[options]
+server_wide_modules = web,openupgrade_framework
+
+

When you load the module in either way of these ways, and you have the +openupgrade_scripts module in your addons path available, the +–upgrade-path option of Odoo will be set automatically to the location +of the OpenUpgrade migration scripts.

+
+
+

Development

+

The odoo_patch folder contains python files in a tree that mimicks the +folder tree of the Odoo project. It contains a number of monkey patches +to improve the migration of an Odoo database between two major versions.

+

So far, we are able to make everything work without overwriting large +blocks of code, but if larger patches need to be added, please use the +method described below:

+

To see the patches added, you can use meld tools:

+

meld PATH_TO_ODOO_FOLDER/odoo/ PATH_TO_OPENUPGRADE_FRAMEWORK_MODULE/odoo_patch

+

To make more easy the diff analysis :

+
    +
  • Make sure the python files has the same path as the original one.
  • +
  • Keep the same indentation as the original file. (using if True: +if required)
  • +
  • Add the following two lines at the beginning of your file, to avoid +flake8 / pylint errors
  • +
+
+# flake8: noqa
+# pylint: skip-file
+
+
    +
  • When you want to change the code. add the following tags:
  • +
+

For an addition:

+
+# <OpenUpgrade:ADD>
+some code...
+# </OpenUpgrade>
+
+

For a change:

+
+# <OpenUpgrade:CHANGE>
+some code...
+# </OpenUpgrade>
+
+

For a removal:

+
+# <OpenUpgrade:REMOVE>
+# Comment the code, instead of removing it.
+# </OpenUpgrade>
+
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Therp BV
  • +
  • Opener B.V.
  • +
  • GRAP
  • +
  • Hunki Enterprises BV
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

Many developers have contributed to the OpenUpgrade framework in its +previous incarnation. Their original contributions may no longer needed, +or they are no longer recognizable in their current form but OpenUpgrade +would not have existed at this point without them.

+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainers:

+

legalsylvain StefanRijnhart hbrunn

+

This module is part of the OCA/OpenUpgrade project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/openupgrade_framework/tests/__init__.py b/openupgrade_framework/tests/__init__.py new file mode 100644 index 000000000000..f0425e721034 --- /dev/null +++ b/openupgrade_framework/tests/__init__.py @@ -0,0 +1 @@ +from . import test_openupgrade_framework diff --git a/openupgrade_framework/tests/test_openupgrade_framework.py b/openupgrade_framework/tests/test_openupgrade_framework.py new file mode 100644 index 000000000000..4a763142f32f --- /dev/null +++ b/openupgrade_framework/tests/test_openupgrade_framework.py @@ -0,0 +1,35 @@ +from odoo.tests.common import TransactionCase +from odoo.tools.misc import mute_logger + +from odoo.addons.base.models.ir_model import MODULE_UNINSTALL_FLAG + + +class TestOpenupgradeFramework(TransactionCase): + def test_01_delete_undeletable_record(self): + """ + Test that Odoo doesn't crash when deleting records that can't be deleted + during module upgrade + """ + with ( + mute_logger("odoo.sql_db"), + self.assertLogs( + "odoo.addons.openupgrade_framework.odoo_patch.odoo.orm.models" + ), + ): + self.env.ref("base.partner_admin").with_context( + **{MODULE_UNINSTALL_FLAG: True} + ).unlink() + + def test_02_invalid_view(self): + """ + Test that we patch away fatal view errors and log the problem + """ + with self.assertLogs( + "odoo.addons.openupgrade_framework.odoo_patch.odoo.addons.base.models.ir_ui_view" + ): + self.env["ir.ui.view"].create( + { + "model": "res.partner", + "arch": '
', + } + ) diff --git a/openupgrade_scripts/README.rst b/openupgrade_scripts/README.rst new file mode 100644 index 000000000000..3ab5666ceaf2 --- /dev/null +++ b/openupgrade_scripts/README.rst @@ -0,0 +1,92 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +=================== +Openupgrade Scripts +=================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:822b62802d167eb9c5a7f7fe5a2ec56b891dd6aa8e81d31929e0f123f1e8346f + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2FOpenUpgrade-lightgray.png?logo=github + :target: https://github.com/OCA/OpenUpgrade/tree/19.0/openupgrade_scripts + :alt: OCA/OpenUpgrade +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/OpenUpgrade-19-0/OpenUpgrade-19-0-openupgrade_scripts + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/OpenUpgrade&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module is a containers of migration script to migrate from 18.0 to +19.0 version. + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +This module does not need to be installed on a database. It simply needs +to be available via your ``addons-path``. + +Configuration +============= + +- call your odoo instance with the option + ``--upgrade-path=/PATH_TO_openupgrade_scripts_MODULE/scripts/`` + +or + +- add the key to your configuration file: + +.. code:: shell + + [options] + upgrade_path = /PATH_TO_openupgrade_scripts_MODULE/scripts/ + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/OpenUpgrade `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/openupgrade_scripts/__init__.py b/openupgrade_scripts/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/openupgrade_scripts/__manifest__.py b/openupgrade_scripts/__manifest__.py new file mode 100644 index 000000000000..0d588aa418cd --- /dev/null +++ b/openupgrade_scripts/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright Odoo Community Association (OCA) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "Openupgrade Scripts", + "summary": """Module that contains all the migrations analysis + and scripts for migrate Odoo SA modules.""", + "author": "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/OpenUpgrade", + "category": "Migration", + "version": "19.0.1.0.0", + "license": "AGPL-3", + "depends": ["base"], + "images": ["static/description/banner.jpg"], + "external_dependencies": {"python": ["openupgradelib"]}, + "installable": True, +} diff --git a/openupgrade_scripts/apriori.py b/openupgrade_scripts/apriori.py new file mode 100644 index 000000000000..ad2269309acc --- /dev/null +++ b/openupgrade_scripts/apriori.py @@ -0,0 +1,30 @@ +"""Encode any known changes to the database here +to help the matching process +""" + +# Renamed modules is a mapping from old module name to new module name +renamed_modules = { + # odoo + # odoo/enterprise + # OCA/... +} + +# Merged modules contain a mapping from old module names to other, +# preexisting module names +merged_modules = { + # odoo + # odoo/enterprise + # OCA/... +} + +# only used here for upgrade_analysis +renamed_models = { + # odoo + # OCA/... +} + +# only used here for upgrade_analysis +merged_models = { + # odoo + # OCA/... +} diff --git a/openupgrade_scripts/pyproject.toml b/openupgrade_scripts/pyproject.toml new file mode 100644 index 000000000000..4231d0cccb3d --- /dev/null +++ b/openupgrade_scripts/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/openupgrade_scripts/readme/CONFIGURE.md b/openupgrade_scripts/readme/CONFIGURE.md new file mode 100644 index 000000000000..102ae2481b2f --- /dev/null +++ b/openupgrade_scripts/readme/CONFIGURE.md @@ -0,0 +1,11 @@ +- call your odoo instance with the option + `--upgrade-path=/PATH_TO_openupgrade_scripts_MODULE/scripts/` + +or + +- add the key to your configuration file: + +``` shell +[options] +upgrade_path = /PATH_TO_openupgrade_scripts_MODULE/scripts/ +``` diff --git a/openupgrade_scripts/readme/DESCRIPTION.md b/openupgrade_scripts/readme/DESCRIPTION.md new file mode 100644 index 000000000000..23d24b62fdff --- /dev/null +++ b/openupgrade_scripts/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module is a containers of migration script to migrate from 18.0 to +19.0 version. diff --git a/openupgrade_scripts/readme/INSTALL.md b/openupgrade_scripts/readme/INSTALL.md new file mode 100644 index 000000000000..471a1d162ce1 --- /dev/null +++ b/openupgrade_scripts/readme/INSTALL.md @@ -0,0 +1,2 @@ +This module does not need to be installed on a database. It simply needs +to be available via your `addons-path`. diff --git a/openupgrade_scripts/static/description/banner.png b/openupgrade_scripts/static/description/banner.png new file mode 100644 index 000000000000..9dd67ec04cf4 Binary files /dev/null and b/openupgrade_scripts/static/description/banner.png differ diff --git a/openupgrade_scripts/static/description/icon.png b/openupgrade_scripts/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/openupgrade_scripts/static/description/icon.png differ diff --git a/openupgrade_scripts/static/description/index.html b/openupgrade_scripts/static/description/index.html new file mode 100644 index 000000000000..bcf94d1af849 --- /dev/null +++ b/openupgrade_scripts/static/description/index.html @@ -0,0 +1,438 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Openupgrade Scripts

+ +

Beta License: AGPL-3 OCA/OpenUpgrade Translate me on Weblate Try me on Runboat

+

This module is a containers of migration script to migrate from 18.0 to +19.0 version.

+

Table of contents

+ +
+

Installation

+

This module does not need to be installed on a database. It simply needs +to be available via your addons-path.

+
+
+

Configuration

+
    +
  • call your odoo instance with the option +--upgrade-path=/PATH_TO_openupgrade_scripts_MODULE/scripts/
  • +
+

or

+
    +
  • add the key to your configuration file:
  • +
+
+[options]
+upgrade_path = /PATH_TO_openupgrade_scripts_MODULE/scripts/
+
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/OpenUpgrade project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000000..180fc49789ba --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +# generated from manifests external_dependencies +openupgradelib