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:
- If there are any, run the add-on preinit hook.
- Load the model definitions from the Python source code and update the database structure, if necessary (refer to Chapter 5, Application Models, for details).
- Load the data files of the add-on and update the database contents, if necessary (refer to Chapter 7, Module Data, for details).
- Install the add-on demo data if demo data has been enabled in the instance.
- If there are any, run the add-on postinit hook.
- Run a validation of the view definitions of the add-on.
- If demo data is enabled and a test is enabled, run the tests of the add-on (refer to Chapter 18, Automated Test Cases, for details).
- Update the module state in the database.
- Update the translations in the database from the add-on's translations (refer to Chapter 12, Internationalization, for details).
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 4, Creating Odoo Modules.