We check if OpenUpgrade scripts from the core modules are already migrated to the latest version, and if we cover all the functionality needed with them. To check so, there's the official documentation: https://oca.github.io/OpenUpgrade/index.html
We need to consider also those modules that are installed in the production instance which don't appear in our inventory, as they could generate issues in the future. We need to make sure the inventory is updated before starting the migration process. To check so, we run this query:
select write_uid from ir_module_module group by write_uid;
The migration process is shown in the following image:
To build this environment:
In our project repository, we'll create a branch for each intermediate version and for the final version, leaving the actual branch as the main one. Those branches will be deleted after the migration, leaving only the last version one which will convert to the main one.
For each one of those branches, we'll create some environment variables (XX is the Odoo version, ex. 12, 13. 14…):
Make sure you are using the last Odoo Provisioning Version tag
Regarding the Python version used in each Odoo version, we use Python 3.7.13 until v14, Python 3.8.12 for Odoo v15 and Python 3.10.13 for Odoo v16.
That will allow us to have different virtual environments (one for each Odoo version) in the same container. In each version (excepting the initial one where we'll provide the actual Odoo state), we'll provide:
For versions equal or lower than Odoo v13, we'll provide an OpenUpgrade Odoo mirror: https://git.coopdevs.org/coopdevs/odoo/migrations/openupgrade-mirror/-/releases
For versions equal or higher than Odoo v14, we'll provide a normal Odoo image, including the OpenUpgrade OCA modules.
Always make sure to use the last version of openupgrade:
In our NextCloud, we create a pad where we'll write down all the modifications we do to fix our database, in order to replicate the process in the final migration.
We execute sanity previous queries:
Helpdesk mail templates
Back accounts without assigned partner:
select acc_number, partner_id from res_partner_bank where partner_id is null;
In case an Odoo v12 uses Cooperator (Easy-my-coop), we need to move from Easy-My-Coop modules to Cooperator inside Odoo v12. To do so, we run previously the script provided by Coop IT Easy. Afterwards, inside v12, we update the cooperator modules by executing the Odoo Instance with --update cooperator --stop-after-init
We execute the migration scripts. To do so:
For versions equal or lower than Odoo v13, we execute Odoo instance with --update all --stop-after-init
For versions equal or higher than Odoo v14:
Insert into /etc/odoo_xx/odoo.conf: server_wide_modules=base,web,openupgrade_framework
We add the upgrade path into the Odoo instance execution: --upgrade-path=/home/odoo/pyenv/versions/odoo-X/lib/python3.X/site-packages/odoo/addons/openupgrade_scripts/scripts --update all --stop-after-init
We fix errors during the migration, iterating in the process and filling the pad with the executed queries
When we succeed to finish a migration process to a new version, it's important to check the functional behavior, checking new and old dependencies:
If the module is available in this new version, we install it inside the virtualenv, put in the inventory and repeat this process for the following versions.
If the module is not available but will be in the following versions, we do nothing.
If the module is deprecated or not available in this version and future versions, we uninstall it from the UI.
Once we've finished the process, we clean up the database uninstalling the unused modules and regenerating assets from the UI.
We set up a development instance to allow both the functional team and the customer to test and validate all the functionality before the final migration.
It happens that in Odoo v16 you cannot backup a database from the UI. Instead, we use this tool to backup and afterwards we copy using SCP.
Once we've validated the functionality in our development instance and we've scheduled the final migration, we need to:
Hire a new production server with the same performance than the actual one, updating the operating system.
Redirect the production domain to this new machine or create a specific owned domain to provide this instance. Make sure at this point to define the steps to execute in order to avoid certificate, backups and monitoring duplicates or issues.
Create a new Backups bucket for this machine.
Provision the new machine enabling monitoring. We use the same backups credentials with a new bucket and restic password. If failban gives and error while provisioning:
Backup the production database. We deactivate crons and mails before executing the backup.
Shutdown the production server instance
Redirect DNS to the new server instance or ask the client to do so. Make sure not to generate a BackupExporter twice when providing certificates for the customer domain in the server.
Repeat the migration process following the documentation we created in the development phase.
Restore the migrated database into the new production instance, and check that functionality, backups and monitoring is working as expected. We reactivate crons and mails after this validation.
If the URL domain has changed because of the migration, we modify the monitor-provisioning project in order to update SysAdmin Alerts.
We merge the final version branch into master, with all the changes implemented (make sure odoo_xx environment variables are placed in local config.yml)