使用 Odoo 服务
您可以进行以下更改:
- 停止服务器:
systemctl stop odoo
- 启动服务器:
systemctl start odoo
。这里会更新 .py
文件。
- 如果您还需要更新
xml
或某些翻译,可以在 Odoo 界面上的模块描述表单中按下 更新
按钮。
注意:有一些模块可以重新加载特定的 xml 视图。如果您感兴趣,我可以查看并找到相应的模块。
不使用 Odoo 服务
如果您在本地开发,无需使用 systemctl
。只需直接运行 odoo.py
,即可立即查看更改内容:
./odoo.py -c openerp-server.conf -u <my_module_name> -d <database_name>
自动重新加载Python文件
当Python文件发生更改时,有另一种选项可以重新加载它们。请查看其他答案:
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.
在Odoo 10中,只需添加
--dev=reload
参数即可。
--dev=DEV_MODE Enable developer mode. Param: List of options
separated by comma. Options : all,
[pudb|wdb|ipdb|pdb], reload, qweb, werkzeug, xml