Last active
October 24, 2025 03:41
-
-
Save ryanc-me/54e42950a806d87aff83fd02d92141d4 to your computer and use it in GitHub Desktop.
Odoo OCA Upgrade
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # What is this? | |
| # | |
| # A script to assist with setting up a multi-version upgrade via OpenUpgrade | |
| # | |
| # | |
| # Why do we need it? | |
| # | |
| # Cloning all of the repos, gathering config files, etc is tedious and error-prone | |
| # | |
| # | |
| # Why not via a Docker container or $some_other_method? | |
| # | |
| # Use whichever method you prefer :-) | |
| sudo mkdir /opt/upgrade | |
| sudo chown -R $(whoami): /opt/upgrade | |
| cd /opt/upgrade | |
| # excluding the current version, including the target + all intermediaries | |
| # e.g., this is 10.0 -> 18.0 | |
| versions=(11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0) | |
| target_version="18.0" | |
| # clone the OpenUpgrade scripts | |
| for v in ${versions[*]}; do | |
| git clone [email protected]:OCA/OpenUpgrade.git -b $v --single-branch --depth 1 ./$v/OpenUpgrade | |
| done | |
| #OR, update | |
| for v in ${versions[*]}; do | |
| cd ./$v/OpenUpgrade | |
| git pull origin $v | |
| cd ../../ | |
| done | |
| # clone Odoo | |
| for v in ${versions[*]}; do | |
| # only required for 14.0+ | |
| version=$(awk '{print $1+0}' <<< "$v") | |
| if [ "$version" -ge "14" ]; then | |
| git clone [email protected]:odoo/odoo.git -b $v --single-branch --depth 1 ./$v/odoo | |
| fi | |
| done | |
| #OR, update | |
| for v in ${versions[*]}; do | |
| # only required for 14.0+ | |
| version=$(awk '{print $1+0}' <<< "$v") | |
| if [ "$version" -ge "14" ]; then | |
| cd ./$v/odoo | |
| git pull origin $v | |
| cd ../../ | |
| fi | |
| done | |
| # Odoo conf | |
| cat <<EOF > odoo.pre14.conf | |
| [options] | |
| db_user = odoo | |
| addons_path = OpenUpgrade/odoo/addons,OpenUpgrade/addons | |
| limit_time_cpu = 999999999999 | |
| limit_time_real = 999999999999 | |
| limit_memory_soft = 999999999999 | |
| limit_memory_hard = 999999999999 | |
| server_wide_modules = base,web | |
| EOF | |
| cat <<EOF > odoo.conf | |
| [options] | |
| db_user = odoo | |
| addons_path = odoo/odoo/addons,odoo/addons,OpenUpgrade | |
| limit_time_cpu = 999999999999 | |
| limit_time_real = 999999999999 | |
| limit_memory_soft = 999999999999 | |
| limit_memory_hard = 999999999999 | |
| upgrade_path = OpenUpgrade/openupgrade_scripts/scripts | |
| server_wide_modules = base,web,openupgrade_framework | |
| EOF | |
| # upgrade script | |
| cat <<EOF > upgrade.pre14.sh | |
| #!/bin/bash | |
| dbname="\$1" | |
| workdir="\$(dirname \$(realpath "\$0"))" | |
| sudo su - odoo -s /bin/bash -c "\\ | |
| cd \\"\$workdir\\" && \\ | |
| export OPENUPGRADE_TARGET_VERSION=\\"$target_version\\" && \\ | |
| ./venv/bin/python3 OpenUpgrade/odoo-bin -c odoo.conf -d \\"\$dbname\\" -u all --stop-after-init --no-http --workers 0 --logfile /nope 2>&1 | tee upgrade.log \\ | |
| " | |
| EOF | |
| cat <<EOF > upgrade.sh | |
| #!/bin/bash | |
| dbname="\$1" | |
| workdir="\$(dirname \$(realpath "\$0"))" | |
| sudo su - odoo -s /bin/bash -c "\\ | |
| cd \\"\$workdir\\" && \\ | |
| export OPENUPGRADE_TARGET_VERSION=\\"$target_version\\" && \\ | |
| ./venv/bin/python3 odoo/odoo-bin -c odoo.conf -d \\"\$dbname\\" -u all --stop-after-init --no-http --workers 0 --logfile /nope 2>&1 | tee upgrade.log \\ | |
| " | |
| EOF | |
| cat <<EOF > shell.pre14.sh | |
| #!/bin/bash | |
| dbname="\$1" | |
| workdir="\$(dirname \$(realpath "\$0"))" | |
| sudo su - odoo -s /bin/bash -c "\\ | |
| cd \\"\$workdir\\" && \\ | |
| ./venv/bin/python3 OpenUpgrade/odoo-bin shell -c odoo.conf -d \\"\$dbname\\" --no-http --workers 0 --logfile /nope \\ | |
| " | |
| EOF | |
| cat <<EOF > shell.sh | |
| #!/bin/bash | |
| dbname="\$1" | |
| workdir="\$(dirname \$(realpath "\$0"))" | |
| sudo su - odoo -s /bin/bash -c "\\ | |
| cd \\"\$workdir\\" && \\ | |
| ./venv/bin/python3 odoo/odoo-bin shell -c odoo.conf -d \\"\$dbname\\" --no-http --workers 0 --logfile /nope \\ | |
| " | |
| EOF | |
| sudo chmod +x upgrade.pre14.sh upgrade.sh shell.pre14.sh shell.sh | |
| for v in ${versions[*]}; do | |
| version=$(awk '{print $1+0}' <<< "$v") | |
| if [ "$version" -lt "14" ]; then | |
| cp ./odoo.pre14.conf $v/odoo.conf | |
| cp ./upgrade.pre14.sh $v/upgrade.sh | |
| cp ./shell.pre14.sh $v/shell.sh | |
| else | |
| cp ./odoo.conf $v/odoo.conf | |
| cp ./upgrade.sh $v/upgrade.sh | |
| cp ./shell.sh $v/shell.sh | |
| fi | |
| done | |
| # install deadsnakes (for Python 3.8, etc) | |
| sudo apt install -y software-properties-common | |
| sudo add-apt-repository -y ppa:deadsnakes/ppa | |
| sudo apt install -y python3.7 python3.7-distutils python3.7-dev | |
| sudo apt install -y python3.8 python3.8-distutils python3.8-dev | |
| sudo apt install -y python3.12 python3.12-dev | |
| # virtualenvs | |
| for v in ${versions[*]}; do | |
| version=$(awk '{print $1+0}' <<< "$v") | |
| if [ "$version" -le "11" ]; then | |
| virtualenv --python=python3.7 $v/venv | |
| $v/venv/bin/pip3 install setuptools==58 | |
| elif [ "$version" -le "13" ]; then | |
| virtualenv --python=python3.8 $v/venv | |
| $v/venv/bin/pip3 install setuptools==58 | |
| elif [ "$version" -le "16" ]; then | |
| virtualenv --python=python3.8 $v/venv | |
| else | |
| # virtualenv for newer Python versions are installing binaries | |
| # to ./venv/local/bin instead of ./venv/bin | |
| # this might not be required for >3.10 | |
| DEB_PYTHON_INSTALL_LAYOUT='deb' virtualenv --python=python3.12 $v/venv | |
| fi | |
| done | |
| # python reqs | |
| for v in ${versions[*]}; do | |
| $v/venv/bin/pip3 install -r $v/odoo/requirements.txt | |
| $v/venv/bin/pip3 install -r $v/OpenUpgrade/requirements.txt | |
| done | |
| # logfile | |
| for v in ${versions[*]}; do | |
| sudo touch $v/upgrade.log | |
| sudo chown odoo:enabling $v/upgrade.log | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment