oca-port, the tool to easily migrate and maintain (OCA) modules from one Odoo version to another
Sébastien Alix, author of the this module, explains how oca-port can help any Odoo developer and OCA contributor


What’s the goal of oca-port?

The aim of this tool is to facilitate the migration of OCA modules, as well as the porting of functionalities or corrections from one Odoo version to another for modules that have already been migrated (forward-port or backport).

In short, it is used to migrate and maintain Odoo modules on several versions, in order to guarantee the same functional coverage everywhere.

Who is oca-port made for?

oca-port is both:

  • a command line interface (CLI) tool for developers and maintainers to help them in their day-to-day work

  • a programming interface (API) that can be used to build reporting tools


Why and how did you create this tool?

As some of our Odoo projects at CamptoCamp include a large number of OCA modules (several hundred), we needed a tool to facilitate their maintenance and monitoring, particularly when migrating to a new version of Odoo.

What is the advantage of using the oca-port module?

As the different branches on the OCA repositories are created ‘from scratch’ (empty) for each new version of Odoo, this means that a given module will have different git histories for each version of Odoo. So you can't use all the git features to easily forward-port/backport changes from one branch to another, as the histories are different.

Without oca-port, it is necessary to visually compare the different git histories of a module, and to sort out what is already present in one version compared to another, and what is not.

Then, for each change (commit), you need to perform a git cherry-pick (if possible in the right order to avoid conflicts as much as possible).

The main function of oca-port is to compare two unrelated git histories (two Odoo versions) for a given module, and to draw up a list of what is missing in the target version compared with the source version.

Are there other similar tools out there?

To my knowledge, there is no other tool that does similar things (compare git histories.)

However, for the initial migration of the git history when migrating a module to a new version, oca-port and https://github.com/OCA/odoo-module-migrator have the same functionality.

To sum up:

  • oca-port compares two git histories, produces a report, and assists the developer in porting missing changes from one version to another, or in migrating the module if this has not already been done. But it is above all a maintenance tool.

  • odoo-module-migrator helps the developer migrate a module to a new version, and transforms the code to suit the targeted Odoo version.

The good news is that these two tools complement each other, and work is underway to integrate odoo-module-migrator into oca-port so that the latter can automatically migrate module code when a module is migrated (see PR https://github.com/OCA/oca-port/pull/53).

Could you share with us several concrete use cases?

Let's imagine an Odoo project that started in version 14.0, with the OCA/account-invoicing account_invoice_section_sale_order module installed.

Over time, versions 15.0, 16.0 and even 17.0 of Odoo have been released, and the OCA module has been ported to each of these versions.

However, patches and new functionalities were developed for the 14.0 version after the module had been migrated to subsequent versions: we end up with changes that are present in 14.0, but non-existent in 15.0, 16.0 and 17.0!

To list (and then port) these changes, we can use the following command in a local copy of the OCA/account-invoicing repository:

  $ oca-port origin/14.0 origin/15.0 account_invoice_section_sale_order --verbose --fetch --destination camptocamp/15-port-from-14-account_invoice_section_sale_order

Then from version 15.0 to 16.0, and from 16.0 to  17.0. oca-port help us to open those Pull Requests :

The aim is to ensure that these changes are in place when the module is migrated to 18.0, to avoid any regression when the project is migrated to a later version.

Can oca-port be used to maintain custom code as well?

Yes, you can use this tool to migrate/maintain modules in your own repositories (by modifying a few command line parameters). For example at CamptoCamp, it is used both to :

  • migrate/maintain generic modules hosted in OCA repositories (public or private)

  • migrate/maintain specific modules within a customer project, particularly if changes have been made in the production branch after a migration project to a later version has begun for that customer (which can take months): listing and porting these changes then becomes easy so that nothing is forgotten during the Go-Live to the new version.

Where can we find this tool?

This tool is developed under the OCA umbrella, on its GitHub repository. It is also available on PyPI as any OCA module:

Who are the current contributors of this module?

The main developer is myself, Sébastien Alix. 

Simone Orsi also contributes from time to time. Other contributors are starting to get involved, particularly via bug reports and idea submissions.


For those who want to learn more about it, where can they go?

The first version of oca-port was presented during the 2022 OCA Days edition:
https://www.youtube.com/watch?v=idGLkQiJ5N0&pp=ygUIb2NhLXBvcnQ%3D

 

Odoo Community Association (OCA), Virginie Dewulf 16 December, 2024
Share this post
Archive
Sign in to leave a comment
OpenUpgrade
Project Update