This question has been flagged
7 Replies
16627 Views

I've a very basic question of why odoo restart is required when making some changes in python files. I've read this https://www.odoo.com/forum/help-1/question/is-there-a-need-to-restart-openerp-server-when-we-update-a-custom-module-52293, and it says restart is mandatory but didn't say why it's mandatory.

On a running server if i can move a module to addons path and install it (without restarting server) why am i not able to modify python file and upgrade the module.

And if python is interpreted why do i need a restart?

Additionally i've even tried deleting the pycache directory to see if that restricts the interpreter from further compiling it, but it didn't help.

And i'm very clear that module upgradation is required if we modify xml files. No more explanation required on the same. :)

Meanwhile i'm trying to explore if i can modify the python files and tell odoo in someway other than restarting it. Thanks in advance for clarifying me.

Avatar
Discard

To Configure watchdog with Odoo to restart the odoo service automatically, see this: https://www.youtube.com/watch?v=SKwl_pSBy9c

Best Answer

You will need to install watchdog to have auto reload option working. Watchdog is available on linux. So whenever you save changes to any of the files under watch, the server will be auto restarted.

e.g.  You can see here:

https://www.awesomescreenshot.com/image/3303625/d6a4656e3d85fa5cd797e6efdfe23619

Avatar
Discard
Author

Thanks Devendran. Does it work for mac?

Best Answer

Hi everyone, --dev reload work with enterprise?

Avatar
Discard
Best Answer

Python code is compiled, then interpreted.

Python automatically compiles your script to compiled code, a .pyc file, before running it.

When a NEW module is added and seen for the first time, or when the source is more recent than the current compiled file, a .pyc file containing the compiled code will be created in the same directory as the .py file.  This is why a new addon can be copied and installed without a restart.

After compilation, the sources files are not used by the Server.

Use the --dev reload option to automatically restart after changes WHILE DEVELOPING.

https://www.odoo.com/documentation/11.0/reference/cmdline.html

Avatar
Discard
Author

Thanks Ray Carnes, but --dev reload option didn't help for me in pycharm. Can you please tell me what i miss? Am using mac by the way.

Best Answer

You do need to restart Odoo if you are working only with the Python files, and this is not only "Odooish" stuff, it's common to all python application Django, Flask, Pyramid etc.

To always be on the safer side, you can add this flag to your odoo startup command --dev=all, this will enable Odoo to keep watch on any changes made to python file(s), and reload the server by itself, but only works for python files, as for xml you may still need to restart.


Avatar
Discard