Search Here

Getting odoo modules and files path

In this tutorial I am going to show you how to get working odoo module directory, sub directories and file path. To get path of a module we have to import python standard library named os.

Getting odoo modules and files path


Get current working python file path

1- print(__file__)
2- os.path.abspath(__file__)
Output: D:\odoo\trunk\your_module\models.py

Get current working python file name

os.path.basename(__file__)
Output: models.py

Get current working module path

1- os.path.dirname(os.path.realpath(__file__))
2- os.path.dirname(__file__)
Output: D:\odoo\trunk\your_module

Get current working module name

os.path.basename(os.path.dirname(__file__))
Output: your_module

Don,t forgot to share, keep sharing keep learning

Post a Comment

0 Comments