Upgrade Odoo Apps From Command Line
Luckily not as difficult as it seems.
Every once in a while, you will run into an issue during Odoo development that causes an internal server error in one of your Odoo databases. This could be caused by some different issues:
- Pulling down code updates without restarting the odoo processes, preventing python files from generating the proper .pyc files.
- Not properly updating the applications that were affecting from pulling down code changes.
- Not updating across all databases that have the effected applications installed.
Let’s assume we have one Odoo instance currently running. I can view the processes by running a ps aux and greping for the script name.
Let’s also assume that a production database has been properly updated but a testing database is currently throwing an internal server error because it was not properly updated.
We do not want to take down any currently running processes, but we need to bring up that bad database. It’s not too hard to do that through command line.
This command will spin up a new Odoo instance, on a separate port, and try to upgrade a list of modules on a single database. After it runs through all the initialization processes for Odoo it kills itself. Here’s what each flag means.
This is the path to the configuration file. It should be the same configuration file that you are already pointing your Odoo instance to run against. If you are not using any type of configuration file now, then you will just need to use all the same flags that you typically run, except for the parameters listed below. These should take precedence in this case.
This is the name of the database you want to try to upgrade the modules on. In my simple example above, where a production database is running and the testing database is down, this is the database we are trying to fix.
A comma separated list of problem modules that need to be upgraded.
This is a flag forcing Odoo to kill the process after all initialization logic has finished. This allows us to just recompile pyc files, upgrade modules, and then stop since we just this to all happen via command line.
Make sure that this is a different port from the processes that are already running for your current Odoo instance. If it is, you will see an error message pop up that says the port is already in use.
And that is it. Happy coding :)