콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
3703 화면

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!

아바타
취소
베스트 답변

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

아바타
취소
베스트 답변

Hi,

Try like following

from odoo.addons.new_module_2.model_file_that_i_use import AFunction

Regards

아바타
취소
작성자

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?

관련 게시물 답글 화면 활동
1
12월 22
16492
1
3월 15
9718
1
10월 23
97
1
3월 21
18555
0
6월 17
6799