Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
25390 Tampilan

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

Avatar
Buang

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

Penulis

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

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

Penulis Jawaban Terbai

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.

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
2
Agu 24
887
2
Agu 20
5357
2
Feb 25
642
0
Des 24
518
1
Apr 23
4655