Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

import an external file to a custom module

By
Wided
on 9/26/13, 6:13 AM 1,255 views

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?

1

Brett Lehrer

--Brett Lehrer--
1252
| 5 4 8
Milwaukee, United States
--Brett Lehrer--
Director of IT and open source enthusiast.
Brett Lehrer
On 10/24/13, 3:20 AM

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.

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.

Wided
on 10/24/13, 5:26 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 9/26/13, 6:13 AM
Seen: 1255 times
Last updated: 3/16/15, 8:10 AM