Installing and upgrading local addon modules

The core of the functionality of Odoo comes from the addon modules. You have a wealth of addons available as part of Odoo itself as well as addon modules that you can download from the Internet or write yourself.

In this recipe, we will show how to install and upgrade addon modules through the web interface and from the command line.

The main benefits of using the command line for these operations are being able to act on more than one addon at a time and having a clear view of the server logs as the installation or update progresses, which is very useful when in the development mode or when scripting the installation of an instance.

Getting ready

You have an Odoo instance with its database initialized, the addons path is properly set, and the addons list is up to date.

How to do it…

There are two possible methods to install or update addons—you can use the web interface or the command line.

From the web interface

To install a new addon module in your database using the web interface, use the following steps:

  1. Connect to the instance using the Administrator account. Open the Apps menu:
    From the web interface
  2. Click on Apps.
  3. Use the search box to locate the addon you want to install. Here are few tips to help you in this task:
    • Activate the Not Installed filter
    • If looking for a specific functionality addon rather than a broad functionality addon, remove the Apps filter
    • Type a part of the module name in the search box, and use this as a Module filter
    • You may find that using the list view gives something more readable
  4. Click on the Install button under the module name (in the icons view or in the form view).

To update an already installed module in your database, use the following steps:

  1. Connect to the instance using the Administrator account.
  2. Open the Apps menu.
  3. Click on Apps:
    From the web interface
  4. Use the search box to locate the addon you want to install. A few tips:
    • Activate the Installed filter
    • If looking for a specific functionality addon rather than a broad functionality addon, remove the Apps filter
    • Type a part of the addon module name in the search box, and use this a Module filter
    • You may find that using the list view gives something more readable
  5. Display the module in the form view, and click on the Upgrade button under the module name.

From the command line

To install some new addons in your database, follow the following steps:

  1. Find the names of the addons. This is the name of the directory containing the file __openerp__.py without the leading path.
  2. Stop the instance. If you are working on a production database, make a backup.
  3. Run the following command:
    $ odoo/odoo.py -c instance.cfg -d dbname -i addon1,addon2 --stop-after-init
    

    Note

    You may omit -d dbname if this is set in your configuration file.

  4. Restart the instance.

To update an already installed addon module in your database, follow the steps given here:

  1. Find the name of the addon module to update; this is the name of the directory containing the __openerp__.py file without the leading path.
  2. Stop the instance. If you are working on a production database, make a backup.
  3. Run the following command:
    $ odoo/odoo.py -c instance.cfg -d dbname -u addon1 
    --stop-after-init
    

    Note

    You may omit -d dbname if this is set in your configuration file.

  4. Restart the instance.

How it works…

The addon module installation and update are two closely related processes, but there are some important differences, as highlighted in the next two sections.

Addon installation

When you install an addon, Odoo checks its list of available addons for an uninstalled addon with the supplied name. It also checks for the dependencies of that addon and, if any, it will recursively install them before installing the addon.

The installation process of a single module consists of the following steps:

  1. If any, run the addon preinit hook.
  2. Load the model definitions from the Python source code and update the database structure if necessary (see Chapter 4, Application Models, for details).
  3. Load the data files of the addon and update the database contents if necessary (see Chapter 9, Module Data for details).
  4. Install the addon demo data if demo data is enabled in the instance.
  5. If any, run the addon postinit hook.
  6. Run a validation of the view definitions of the addon.
  7. If demo data is enabled and test is enabled, run the tests of the addon (see Chapter 7, Debugging and Automated Testing, for details).
  8. Update the module state in the database.
  9. Update the translations in the database from the addon's translations (see Chapter 11, Internationalization for details).

Note

preinit and postinit hooks are defined in the __openerp__.py file using the pre_init_hook and post_init_hook keys, respectively. The value of the key is the name of a Python function which must be defined in the __init__.py file of the addon module. The preinit (resp. postinit) hook is called with a database cursor (resp. a database cursor and a registry object) and may perform modification in the database to prepare (resp. finalize) the module installation. Note that these are not run when the module is updated (you can use migration steps for this, see below).

Addon update

When you update an addon, Odoo checks in its list of available addon modules for an installed addon with the given name. It also checks for the reverse dependencies of that addon (these are the addons that depend on the updated addon), and, if any, it will recursively update them.

The update process of a single addon module consists of the following steps:

  1. Run the addon module's pre migration steps, if any (see Chapter 9, Module Data, for details).
  2. Load the model definitions from the Python source code and update the database structure if necessary (see Chapter 4, Application Models for details).
  3. Load the data files of the addon and update the database contents if necessary (see Chapter 9, Module Data for details).
  4. Update the addon's demo data if demo data is enabled in the instance.
  5. If any, run the addon post migration steps (see Chapter 9, Module Data for details).
  6. Run a validation of the view definitions of the addon.
  7. If demo data is enabled and test is enabled, run the tests of the addon (see Chapter 7, Debugging and Automated Testing, for details).
  8. Update the module state in the database.
  9. Update the translations in the database from the addon's translations (see Chapter 11, Internationalization for details).

Note that updating an addon module which is not installed does nothing at all. However, installing an addon module that is already installed reinstalls the addon, which can have some unintended effects with some data files containing data that is supposed to be updated by the user and not updated during the normal module update process (see Using the noupdate and forcecreate flags in Chapter 9, Module Data). There is no risk of error from the user interface, but this can happen from the command line.

There's more…

Be careful about the dependency handling. Consider an instance where you want to have the addons sale, sale_stock, and sale_specific 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 dependencies sale_stock and sale. 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 is when you add a dependency to an addon that already has a version installed. To continue with the previous example, imagine that you add a dependency on stock_dropshipping in sale_specific. Updating the addon sale_specific will not automatically install the new dependency, neither will requesting the installation of sale_specific. In this situation, you can get very nasty error messages because the Python code of the addon is not successfully loaded but the data of the addon and the models tables in the database are present. To solve this, you need to stop the instance and manually install the new dependency.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.46.58