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.
$ ps aux | grep odoo-server odoo 1995 0.5 4.3 371028 89352 ? Sl 21:13 0:02 python /opt/odoo/core-v8/openerp-server -c /opt/odoo/config/odoo-server-v8.conf odoo 2037 0.0 3.7 371028 77656 ? S 21:13 0:00 python /opt/odoo/core-v8/openerp-server -c /opt/odoo/config/odoo-server-v8.conf odoo 2038 0.0 3.7 371028 77656 ? S 21:13 0:00 python /opt/odoo/core-v8/openerp-server -c /opt/odoo/config/odoo-server-v8.conf odoo 2039 0.0 3.7 371028 77656 ? S 21:13 0:00 python /opt/odoo/core-v8/openerp-server -c /opt/odoo/config/odoo-server-v8.conf odoo 2040 0.0 3.7 371028 77656 ? S 21:13 0:00 python /opt/odoo/core-v8/openerp-server -c /opt/odoo/config/odoo-server-v8.conf odoo 2041 0.7 4.4 376396 90836 ? Sl 21:13 0:02 /usr/bin/python /opt/odoo/core-v8/openerp-gevent -c /opt/odoo/config/odoo-server-v8.conf odoo 2042 0.8 5.6 409264 116300 ? SN 21:13 0:03 python /opt/odoo/core-v8/openerp-server -c /opt/odoo/config/odoo-server-v8.conf odoo 2043 4.7 7.5 447704 154432 ? SN 21:13 0:19 python /opt/odoo/core-v8/openerp-server -c /opt/odoo/config/odoo-server-v8.conf
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.
#!/bin/bash ./openerp-server \ -c /etc/odoo9e-server.conf \ -d Testing \ -u module_name1,module_name2 \ --stop-after-init \ --xmlrpc-port 8090
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 :)
Thanks For Reading
I appreciate you taking the time to read any of my articles. If you're looking for more ramblings, take a look at theentire catalog of articles I've written. Or feel free to give me a follow on Twitter, Instagram, or Github to see what else I've got going on. Or see my contact info below if you want to get in touch with me.