Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
9558 Weergaven

Hello,

In a custom module, I'm trying to import a file that doesn't exist in the addons directory.

My file path: /home/wided/settings.py

Addons path: /usr/local/lib/python2.7/dist-packages/openerp-server/addons

How can I import settings.py to my module?

Avatar
Annuleer
Beste antwoord

Make a symbolic link to the file in your module?

cd /usr/local/lib/python2.7/dist-packages/openerp-server/addons/my_module/
ln -s /home/wided/settings.py

This creates the symlink settings.py in the folder my_module. Then in a different script in that folder,

import settings

I can't think of a situation where I'd want to use this setup over just putting the settings.py file in the module folder itself though. Even making a symlink from the module folder to your home folder sounds like a better idea.

Avatar
Annuleer
Auteur

Thanks for your answer. Actually, I have resolved my problem by copying the file to my module folder. This file serves for an other python project, this is why I didn't want to have it twice in the system. Anyways, your idea is better than mine because when the file is edited, it is edited in both folders.

Gerelateerde posts Antwoorden Weergaven Activiteit
2
okt. 23
3484
1
mrt. 21
18296
1
mrt. 15
4996
2
mei 25
407
4
mei 25
3767