-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Odoo 14 Development Cookbook
By :

The core functionality of Odoo comes from its add-on modules. You have a wealth of add-ons available as part of Odoo itself, as well as add-on modules that you can download from the app store or that have been written by yourself.
In this recipe, we will demonstrate how to install and upgrade add-on modules through the web interface and from the command line.
The main benefits of using the command line for these operations include being able to act on more than one add-on at a time and having a clear view of the server logs as the installation or update progresses, which is very useful when in development mode or when scripting the installation of an instance.
Make sure that you have a running Odoo instance with its database initialized and the add-ons path properly set. In this recipe, we will install/upgrade a few add-on modules.
There are two possible methods to install or update add-ons—you can use the web interface or the command line.
To install a new add-on module in your database using the web interface, perform the following steps:
Figure 2.1 – List of Odoo apps
Note that some Odoo add-on modules have external Python dependencies. If Python dependencies are not installed in your system, then Odoo will abort the installation and it will show the following dialog:
Figure 2.2 – Warning for external library dependency
To fix this, just install the relevant Python dependencies on your system.
To update a pre-installed module in your database, perform the following steps:
Figure 2.3 – Odoo apps list
CRM
and press Enter to search CRM apps.Figure 2.4 – Drop-down link for upgrading the module
Activate developer mode to see the technical name of the module. See Chapter 1, Installing the Odoo Development Environment, if you don't know how to activate developer mode:
Figure 2.5 – Application's technical names
After activating developer mode, it will show the module's technical name in red. If you are using Odoo Community Edition, you will see some extra apps with the Upgrade button. Those apps are Odoo Enterprise Edition apps, and in order to install/use them, you need to purchase a license.
From the command line
To install new add-ons in your database, perform the following steps:
manifest_.py
file, without the leading path.$ odoo/odoo-bin -c instance.cfg -d dbname -i addon1,addon2 \ --stop-after-init
You may omit -d dbname
if this is set in your configuration file.
To update an already installed add-on module in your database, perform the following steps:
manifest_.py
file, without the leading path.$ odoo/odoo-bin -c instance.cfg -d dbname -u addon1 \ --stop-after-init
You may omit -d dbname
if this is set in your configuration file.
The add-on module installation and update are two closely related processes, but there are some important differences, as highlighted in the following two sections.
When you install an add-on, Odoo checks its list of available add-ons for an uninstalled add-on with the supplied name. It also checks for the dependencies of that add-on and, if there are any, it will recursively install them before installing the add-on.
The installation process of a single module consists of the following steps:
preinit
hook.postinit
hook.Note
The preinit
and postinit
hooks are defined in the _manifest_.py
file using the pre_init_hook
and post_init_hook
keys, respectively. These hooks are used to invoke Python functions before and after the installation of an add-on module. To learn more about init
hooks, refer to Chapter 3, Creating Odoo Add-On Modules.
When you update an add-on, Odoo checks in its list of available add-on modules for an installed add-on with the given name. It also checks for the reverse dependencies of that add-on (these are the add-ons that depend on the updated add-on). If any, it will recursively update them, too.
The update process of a single add-on module consists of the following steps:
Note
Note that updating an add-on module that is not installed does nothing at all. However, installing an add-on module that is already installed reinstalls the add-on, which can have some unintended effects with some data files that contain data that is supposed to be updated by the user and not updated during the normal module update process (refer to the Using the noupdate and forcecreate flags recipe in Chapter 6, Managing Module Data). There is no risk of error from the user interface, but this can happen from the command line.
Be careful with dependency handling. Consider an instance where you want to have the sale
, sale_stock
, and sale_specific
add-ons installed, with sale_specific
depending on sale_stock
, and sale_stock
depending on sale
. To install all three, you only need to install sale_specific
, as it will recursively install the sale_stock
and sale
dependencies. To update all three, you need to update sale
, as this will recursively update the reverse dependencies, sale_stock
and sale_specific
.
Another tricky part with managing dependencies is when you add a dependency to an add-on that already has a version installed. Let's understand this by continuing with the previous example. Imagine that you add a dependency on stock_dropshipping
in sale_specific
. Updating the sale_specific
add-on will not automatically install the new dependency, and neither will requesting the installation of sale_specific
. In this situation, you can get very nasty error messages because the Python code of the add-on is not successfully loaded, but the data of the add-on and the models' tables in the database are present. To resolve this, you need to stop the instance and manually install the new dependency.