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

Problems when using "import tools" instead of "import openerp.tools"

By
Andreas Brueckl
on 3/28/13, 12:40 PM 10,619 views

Hello,

I often see modules which are using

import tools

instead of

import openerp.tools

My installation cannot resolve a library without the preceeding "openerp.". I think that this depends on the type of installation and it would not be a problem if a deb-Package is installed.

So my question:

What can I do, than modules without the preceeding "openerp." are working for my installation?

Here is the log of the installation of a module:

File "/opt/openerp/openerp-7.0-bzr/server/openerp/modules/module.py", line 346, in load_openerp_module __import__('openerp.addons.' + module_name) File "/opt/openerp/openerp-7.0-bzr/server/openerp/modules/module.py", line 82, in load_module mod = imp.load_module('openerp.addons.' + module_part, f, path, descr) File "/opt/openerp/addons-elbati/hr_attendance_analysis/__init__.py", line 22, in <module> import hr_attendance File "/opt/openerp/addons-elbati/hr_attendance_analysis/hr_attendance.py", line 24, in <module> from tools.translate import _ ImportError: No module named tools.translate

Hi, for location of your module, did you use same unix user account, same partition disk, it is placed in server/openerp/addons directory, did you use symlink, addons_path option in opeenrp server conf file ? Personnaly by using addons_path option in server conf file I have not this error. Bye

Cyril Gaspard (GEM)
on 3/29/13, 8:40 AM

Thanks for your comment. I try to install module "hr_attendance_analysis" of branch "lp:~elbati/hr-timesheet/adding_hr_attendance_analysis_7". all unix permissions are ok. I tried with addons_path, symlink and direct copy into /server/openerp/addons path without success. I am starting the server in the server directory with ./openerp-server -c /etc/openerp-server-7.conf

Andreas Brueckl
on 4/2/13, 5:23 AM

Hi, with openerp 7 it seems it is now openerp.tools ... which is used. But try to add ..../server/openerp path to pythonpath (search on google how to deine multi path for pythonpath). Should works (I believe deb package installs openerp in python site-packages directory, in this case no problme to find libraries python). Bye

Cyril Gaspard (GEM)
on 4/2/13, 6:01 AM
0

Andreas Brueckl

--Andreas Brueckl--
5056
| 7 8 7
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl
On 4/2/13, 6:15 AM

Thanks to GEM I have solved this issue by dynamically adding the openerp directory to the python path. I have added two lines to file server/openerp-server:

#!/usr/bin/env python
import openerp

# Start ADD
import sys
sys.path.append('openerp')
# End ADD

if __name__ == "__main__":
    openerp.cli.main()

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

However it is strange that I am the only guy who runs openerp without the deb package and focused this issue.

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: 3/28/13, 12:40 PM
Seen: 10619 times
Last updated: 3/16/15, 8:10 AM