How to Create Your Own Github Repository following OCA Style

In general, all Odoo implementers have repositories where they define their own modules. These repositories can be public or private, generic or specific to a client, but that doesn't mean you have to forgo the options provided by the Odoo Community Association (OCA).

In this article, we want to show how you can use the same tools as the OCA in your own modules.

Standardization and Validation

One of the most important aspects of the OCA is code standardization and automatic validation, which greatly simplifies maintenance.

Standardization is achieved by using pre-commit in our repositories. This ensures that our code follows a set of best practices, benefiting us when training new individuals and validating the work done, as it compels everyone to adhere to the same practices.

On the other hand, automatic validation allows us to perform an automatic installation and a testing system that verifies that the code works under certain conditions. While this doesn't guarantee absolute reliability, it provides an extra layer of security when working and verifying the work of our teams.

To configure this, follow these steps from the repository folder:

$ copier copy https://github.com/OCA/oca-addons-repo-template.git/ . --trust

After this command, the system will prompt us with several questions to customize it to our liking, including information such as the Odoo version to use, the repository name, or the organization name.

Once done, we'll have the configuration to use pre-commit natively with any commit. Additionally, automated actions will be executed automatically when creating PRs.

Faster Module Creation

When creating modules, there's a tool that can help us streamline the creation of module and test files. It won't create detailed code but will set up the basic structure to make it easier. This tool is known as mrbob. To create a module, simply use:

$ mrbob bobtemplates.odoo:addon

It will prompt for basic details, and you'll quickly have the basic module structure created. Similarly, you can add a model from a module with:

$ mrbob bobtemplates.odoo:model

It will even ask if you want to create views related to the model.

Bonus Track: Managing Multiple Environments

Consultancies often need to work with different Odoo versions, either due to clients using older versions or testing new or old features. If using a regular on-site installation, this can cause problems, as it requires generating multiple Python environments with their default version depending on the Odoo version being tested.

In such cases, we recommend dockerizing your different environments. By dockerizing, you ensure the use of the specific version required and can even replicate client environments with the same specifications. In our case, we use Doodba, a tool created by Tecnativa.

To use Doodba from your computer, it's most efficient to use the installation template they provide. With it, you'll use copier to answer several questions and automatically generate all the files needed to create the container. If you want to delve deeper into its use, it's best to follow their manuals to get all the necessary information.

Signing documents with OCA