Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
7 Trả lời
20090 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ

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

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks Devendran. Does it work for mac?

Câu trả lời hay nhất

Hi everyone, --dev reload work with enterprise?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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.

Câu trả lời hay nhất

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.


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 12 23
34399
1
thg 11 17
5457
2
thg 8 25
2411
1
thg 7 25
910
1
thg 8 25
1151