Dear all,
I am working on Odoo 12 and need to read the contents of a file that is located on a "static" folder inside my module folder structure.
I am using "os.getcwd()" and it gives me the root folder of my Odoo instalation.
My problem is, on different installations the "custom modules" (addons_path) can be on different locations and this way, my module may fail to work.
Can anyone help me get the exact path to my module root folder in order for me to read the file located at "mymodule/static/myfile.txt"?
Thank you all in advance
Best regards
PM
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
1
Trả lời
11994
Lượt xem
from odoo.modules.module import get_module_resource
text_file_path = get_module_resource('mymodule', 'static/src/, 'myfile.txt')
@Ravi,
Thank you very much my friend.
Exactly what I need.
Best regards
get_module_resource was renamed to get_resource_path in Odoo 10
get_resource_path was deprecated in Odoo 17 in favor of tools.misc.file_path
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 4 25
|
3586 | ||
|
0
thg 3 24
|
1334 | ||
|
0
thg 10 22
|
2519 | ||
|
0
thg 9 22
|
1732 | ||
|
1
thg 7 22
|
5404 |
Try this: https://learnopenerp.blogspot.com/2020/06/getting-odoo-modules-and-files-path.html