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

hello,


i want to import a file to my new custom module, where the file is located at a different custom module like so:


odoo

↳ custom_addon

     ↳ module_1

          ↳ constant

                ↳ i_want_to_import_this_file.py

     ↳ new_module_2

          ↳ model_file_that_i_use.py

↳ odoo


i can't use this line of code on my new model:

[code from model_file_that_i_use.py]

from .module_1.constant.i_want_to_import_this_file.py import AFunction


Error:

ModuleNotFoundError: No module named x



thanks for the help!

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

Use the syntax "odoo.addons.custom_module_name.custom_file_name import..." no matter which directory your custom module is in as long as that module is installed

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

Hi,

Try like following

from odoo.addons.new_module_2.model_file_that_i_use import AFunction

Regards

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

hi thanks for the reply,

but my concern is my custom_addon is outside the main odoo directory. and for some reasons, when i import a file it does not access outside directory from the main /odoo

how can i access the outside folders?

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 12 22
16748
1
thg 3 15
10016
1
thg 10 23
97
1
thg 3 21
18886
0
thg 6 17
7019