Odoo service restart and update using systemctl

fueggit picture fueggit · Mar 19, 2018 · Viewed 7.5k times · Source

Odoo service is started by systemctl start odoo. I am usin Centos. When I want to update my changed *.py code I used to do like this:

1. systemctl stop odoo
Then I update my module and database by useing this:
2. ./odoo.py -c openerp-server.conf -u <my_module_name> -d <database_name>
3. stop service by ctrl + c
4. systemctl start odoo

But it's realy long and uncomfortable way to update changes.

Is there a shorter way to do the same operations in shorter way?

Answer

ChesuCR picture ChesuCR · Mar 19, 2018

Odoo with Service

You can make changes like this:

  1. Stop the server: systemctl stop odoo
  2. Start the server: systemctl start odoo. Here the .py are updated
  3. If you also need to update xml or some translations you can press the Update button on the Odoo interface, on the module description form.

Note: There are modules to reload specific xml views. If you are interested in it I can take a look to check if I find one.

Odoo without Service

If you are developing on your local computer, you don´t need to use systemctl. Just run Odoo directly with odoo.py and you can see the changes immediately:

./odoo.py -c openerp-server.conf -u <my_module_name> -d <database_name>

Autoreload Python Files

There is another option to reload python files when they have changed. Check this other answer:

Normally if you change your python code means, you need to restart the server in order to apply the new changes.

--auto-reload parameter is enabled means, you don't need to restart the server. It enables auto-reloading of python files and xml files without having to restart the server. It required pyinotify. It is a Python module for monitoring filesystems changes.

Just add --auto-reload in your configuration file. By default the value will be "false". You don't need to pass any extra arguments. --auto-reload is enough. If everything setup and works properly you will get

openerp.service.server: Watching addons folder /opt/odoo/v8.0/addons
openerp.service.server: AutoReload watcher running in the server log. Don't forget to install pyinotify package.

But in odoo 10 just add --dev=reload paramter

--dev=DEV_MODE      Enable developer mode. Param: List of options
                    separated by comma. Options : all,
                    [pudb|wdb|ipdb|pdb], reload, qweb, werkzeug, xml