Notes on migrating Odoo from 11 to 12

These are mostly notes to myself, as it’s a somewhat involved process, and the documentation is not very useful. I had to puzzle-piece it together from dozens of form posts and questions, so I hope that this overview will be helpful to others.

Overall process

Odoo does not have an automatic database update when changing between major versions (however, it seems when updating within the same version, the database is adapted and won’t work with older versions).

To update major versions, two parts have to be updated:

  • the code: that’s the easy part, simply uninstall the old version and install the new version. In Ubuntu, I used the apt package manager to uninstall, then updated the repository (odoo nightly builds) from 11 to 12, apt-get update, and apt-get install odoo again.
  • the database: This is the hard part. One way is to switch to the paid enterprise version, and simply let the people at Odoo handle it for you. There are also consulting companies that will do an update against a fee. Or, the DIY method (that this blog is all about…), is to use OpenUpgrade. There are a few pitfalls though.

OpenUpgrade process

OpenUpgrade is a tool that is supposed to take your old database and convert it to the newer version of Odoo.

OpenUpgrade Tip #1: The documentation is bad – very thin on details, outdated, and very confusing. Also, when you look through the github issues, ignore the maintainers who tell people to just go and read the documentation, and insist it’s all there, without offering any help. It’s not, and their attitude is a bit off-putting. Pro-tip: if many people ask “stupid” questions, maybe your documentation isn’t good enough.

The main problem: Apparently there used to be a “migration script”, and a lot of forum posts and tutorials refer to it. It doesn’t exist any more, as it was removed due to too many bugs, according to what I’ve read in the issues. This is not mentioned anywhere.

The way it works now: OpenUpgrade appears to be basically just another patched version of Odoo, with a built-in migration tool. You run it, as you’d run the Odoo server, point it at your database with a few flags, and if all is good, it should update your database. So the overall process is:

Create a local backup instance: (never run an update on your live system!!)

  • install Odoo on a dev machine (not your live system). Make sure you’re running the exact same version of code you’re running on your live system, or the database probably won’t work.
  • download a database dump from your live system, and import it into your dev instance. This can be done either through the web interface (http://localhost:8069/web/database/manager ), or via command line (e.g. instructions here ). You also should transfer the file store and add-ons to your dev machine.
  • test your dev setup, and make sure your data is all there and works.
  • At this point, I used the web database manager to create a duplicate of my database, called “migration” (optional, but it’s good to work on a copy).

Install and run OpenUpgrade:

  • stop the Odoo service (service odoo stop)
  • get OpenUpgrade ( git clone https://github.com/OCA/OpenUpgrade.git )
  • check out branch 12.0 when upgrading from 11 to 12: git checkout 12.0 (you can only upgrade one version at a time).
  • install the newest version of the OpenUpgradeLib: sudo pip3 install --ignore-installed git+https://github.com/OCA/openupgradelib.git@master
  • run OpenUpgrade as the Odoo user with the following flags
    • sudo -u odoo ./odoo-bin -d migration --update all --stop-after-init --data-dir=/tmp (-d gives the database name, in this case called “migration”. I had to set the data dir to /tmp, as the odoo user didn’t have permissions to write in my home folder).
  • There will probably be some errors. In my case, I had some missing python packages, or outdated versions. I installed the newest versions with pip3, in particular psycopg2 and sql. Funnily, although the debian package version of Odoo runs without problem, the OpenUpgrade version didn’t have everything it needed. Also, when using pip to install packages, install them system-wide with sudo, otherwise the odoo user won’t find them.
  • if everything goes well, this should run for a few minutes, giving lots of “INFO” output, and terminate when it’s done. The database should now be updated to the newer version.

Install Odoo v12, and test the migrated database:

  • uninstall version 11 of odoo: sudo apt-get remove odoo
  • edit the repository (/etc/apt/sources.list.d/odoo.list) from 11.0 to version 12.0 (it should look like deb http://nightly.odoo.com/12.0/nightly/deb/ ./ )
  • sudo apt-get update
  • sudo apt-get install odoo
  • open http://localhost:8069/web/database/manager
  • your “migration” database should now appear without an exclamation mark. Select it and try it out. It should work now in version 12. Make sure to test everything thoroughly, before updating your live system and migrating the new database and files back.

This is it. It might take a while to get it running, but it ported all my data across (I think). I hope this detailed step-by-step guide helps.

Leave a Reply

Your email address will not be published. Required fields are marked *