Installing add-on modules from GitHub
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.
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
How to do it…
partner_contact_gender, perform the following steps:
- Go to your project's directory:
$ cd ~/odoo-dev/my-odoo/src
- Clone the
14.0branch of the
partner-contactproject in the
$ git clone --branch 14.0 \ https://github.com/OCA/partner-contact.git src/partner-contact
- Change the add-ons path to include that directory and update the add-ons list of your instance (refer to the Configuring the add-ons path recipe and Updating the add-on modules list recipes in this chapter). The
instance.cfgshould 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
- Install the
partner_contact_genderadd-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).
How it works…
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.