
Odoo 14 Development Cookbook
By :

GitHub is a great source of third-party add-ons. A lot of Odoo partners use GitHub to share the add-ons they maintain internally, and the Odoo Community Association (OCA) collectively maintains several hundred add-ons on GitHub. Before you start writing your own add-on, ensure that you check that nothing already exists that you can use as is or as a starting point.
This recipe will show you how to clone the partner-contact
project of the OCA from GitHub and make the add-on modules it contains available in your instance.
Suppose you want to add new fields to the customers (partner) form. By default, the Odoo customers model doesn't have a gender
field. If you want to add a gender
field, you need to create a new module. Fortunately, someone on a mailing list tells you about the partner_contact_gender
add-on module, which is maintained by the OCA as part of the partner-contact
project.
The paths that are used in this recipe reflect the layout that was proposed in the Standardizing your instance directory layout recipe.
To install partner_contact_gender
, perform the following steps:
$ cd ~/odoo-dev/my-odoo/src
14.0
branch of the partner-contact
project in the src/
directory:$ git clone --branch 14.0 \ https://github.com/OCA/partner-contact.git src/partner-contact
add-ons_path
line of instance.cfg
should look like this:addons_path = ~/odoo-dev/my-odoo/src/odoo/odoo/addons, \ ~/odoo-dev/my-odoo/src/odoo/addons, \ ~/odoo-dev/my-odoo/src/, \ ~/odoo-dev/local-addons
partner_contact_gender
add-on (if you don't know how to install the module, take a look at the previous recipe, Installing and upgrading local add-on modules).All of the Odoo Community Association code repositories have their add-ons contained in separate subdirectories, which is coherent in accordance with what is expected by Odoo regarding the directories in the add-ons path. Consequently, just cloning the repository somewhere and adding that location in the add-ons path is enough.
Some maintainers follow a different approach and have one add-on module per repository, living at the root of the repository. In that case, you need to create a new directory, which you will add to the add-ons path and clone all of the add-ons from the maintainer you need in this directory. Remember to update the add-on modules list each time you add a new repository clone.