Upgrading modules
Developing a module is an iterative process, and you will want changes made on source files to be applied to and made visible in Odoo. We can do this from the GUI, looking up the module in the Apps list and clicking on the Upgrade button.
However, when the changes are only in Python code, the upgrade may not have an effect. Instead of a module upgrade, an application server restart is needed. Since Odoo loads Python code only once, any later changes to code require a server restart to be applied.
In some cases, if the module changes were to both data files and Python code, you might need both operations. This is a common source of confusion for new Odoo developers.
But fortunately, there is a better way. The safest way to make all our changes to a module effective is to stop and restart the server instance, requesting that our modules are upgraded to our work database.
In the terminal where the server instance is running, use Ctrl + C to stop it. Then, start the server and upgrade the library_app module using the following command:
$ ./odoo-bin -d dev12 -u library_app
The -u option (or --update in the long form) requires the -d option and accepts a comma-separated list of modules to update. For example, we could use -u library_app,mail. When a module is updated, all other installed modules depending on it are also updated. This is essential to maintain the integrity of the inheritance mechanisms, used to extend features.
Until Odoo 10.0, before a new addon module could be installed, the module list had to be manually updated from the web client menu option for it to be known to Odoo. Since 11.0, the list of modules available is automatically updated when a module is installed or updated.
Throughout this book, when you need to apply the changes made in the module code files:
- When adding model fields, an upgrade is needed. When changing Python code, including the manifest file, a restart is needed.
- When changing XML or CSV files, an upgrade is needed. When in doubt, do both: restart the server and upgrade the modules.
When in doubt, the safest way is to restart the Odoo instance with the -u <module> option. Pressing the up arrow key brings to you the previous command that was used. So, most of the time, when repeating this action, you will find yourself using the Ctrl + C, up, and Enter key combination.
Or, you can avoid these repeated start/stop actions using the dev=all option. It will automatically reload the changes made to your XML and Python files, as soon as they are saved. See Chapter 2, Preparing the Development Environment, for more details on this option.