[FIX] : Removed tools.config['addons_path'] for bug 666714.

lp bug: https://launchpad.net/bugs/666714 fixed

bzr revid: uco@tinyerp.com-20101026132254-5gkcrrxaskc3aczf
This commit is contained in:
uco (OpenERP)
2010-10-26 18:52:54 +05:30
parent f99028733f
commit b681cb4261
7 changed files with 18 additions and 16 deletions
@@ -26,6 +26,7 @@ import report
from osv import fields, osv, orm
import tools
from tools.translate import _
import addons
class module(osv.osv):
_inherit = 'ir.module.module'
@@ -104,7 +105,7 @@ class module(osv.osv):
context.update({'level': 1})
dots = self.get_graphical_representation(cr, uid, object_ids, context=context)
# todo: use os.realpath
file_path = tools.config['addons_path']+"/base_module_doc_rst/"
file_path = addons.get_module_resource('base_module_doc_rst')
path_png = file_path + "/module.png"
for key, val in dots.items():
path_dotfile = file_path + "/%s.dot" % (key,)
@@ -24,7 +24,7 @@ import os
from osv import fields, osv
from tools.translate import _
import pooler
from tools import config
import addons
from base_module_quality import base_module_quality
class quality_test(base_module_quality.abstract_quality_check):
@@ -45,7 +45,7 @@ This test checks the Unit Test(PyUnit) Cases of the module. Note that 'unit_test
def run_test(self, cr, uid, module_path):
pool = pooler.get_pool(cr.dbname)
module_name = module_path.split('/')[-1]
test_file = config['addons_path'] +'/' + module_name +'/unit_test/test.py'
test_file = addons.get_module_resource(module_name) + '/unit_test/test.py'
if not os.path.isfile(test_file):
self.result += _("Module does not have 'unit_test/test.py' file")
return None
+2 -2
View File
@@ -24,6 +24,7 @@ import os
from osv import fields, osv
import tools
from tools.translate import _
import addons
class hr_employee_category(osv.osv):
@@ -180,8 +181,7 @@ class hr_employee(osv.osv):
return {'value': {'work_email' : work_email}}
def _get_photo(self, cr, uid, context=None):
return open(os.path.join(
tools.config['addons_path'], 'hr/image', 'photo.png'),
return open(addons.get_module_resource('hr','image','photo.png'),
'rb') .read().encode('base64')
_defaults = {
+2 -2
View File
@@ -21,7 +21,7 @@
from osv import fields
from osv import osv
from tools import config
import addons
import base64
@@ -32,7 +32,7 @@ class outlook_installer(osv.osv_memory):
def default_get(self, cr, uid, fields, context={}):
data = super(outlook_installer, self).default_get(cr, uid, fields, context)
data['doc_file'] = 'http://doc.openerp.com/book/2/2_6_Comms/2_6_Comms_outlook.html'
file = open(config['addons_path'] + "/outlook/plugin/openerp-outlook-plugin.zip", 'r')
file = open(addons.get_module_resource('outlook','plugin','openerp-outlook-plugin.zip'), 'r')
data['plugin_file'] = base64.encodestring(file.read())
return data
+2 -2
View File
@@ -40,7 +40,7 @@ import netsvc
import pooler
from report_helper import WebKitHelper
from report.report_sxw import *
from tools.config import config
import addons
from tools.translate import _
from osv.osv import except_osv
@@ -225,7 +225,7 @@ class WebKitParser(report_sxw):
template = False
if report_xml.report_file :
path = os.path.join(config['addons_path'], report_xml.report_file)
path = addons.get_module_resource(report_xml.report_file)
if os.path.exists(path) :
template = file(path).read()
if not template and report_xml.report_webkit_data :
+4 -4
View File
@@ -30,6 +30,7 @@ from osv import osv
from osv import fields
from tools import to_xml
from tools.translate import _
import addons
class survey_question_wiz(osv.osv_memory):
_name = 'survey.question.wiz'
@@ -385,7 +386,7 @@ class survey_question_wiz(osv.osv_memory):
context.update({'response_id':response_id})
report = self.create_report(cr, uid, [int(survey_id)], 'report.survey.browse.response', survey_data.title,context)
attachments = []
file = open(tools.config['addons_path'] + '/survey/report/' + survey_data.title + ".pdf")
file = open(addons.get_module_resource('survey', 'report') + survey_data.title + ".pdf")
file_data = ""
while 1:
line = file.readline()
@@ -395,7 +396,7 @@ class survey_question_wiz(osv.osv_memory):
attachments.append((survey_data.title + ".pdf",file_data))
file.close()
os.remove(tools.config['addons_path'] + '/survey/report/' + survey_data.title + ".pdf")
os.remove(addons.get_module_resource('survey', 'report') + survey_data.title + ".pdf")
user_email = False
resp_email = False
@@ -440,10 +441,9 @@ class survey_question_wiz(osv.osv_memory):
if not report_name or not res_ids:
return (False, Exception('Report name and Resources ids are required !!!'))
try:
ret_file_name = tools.config['addons_path'] + '/survey/report/' + file_name + '.pdf'
service = netsvc.LocalService(report_name);
(result, format) = service.create(cr, uid, res_ids, {}, context)
fp = open(ret_file_name, 'wb+');
fp = open(addons.get_module_resource('survey', 'report') + file_name + '.pdf', 'wb+');
fp.write(result);
fp.close();
@@ -32,6 +32,7 @@ from osv import osv
import tools
from tools.translate import _
import netsvc
import addons
class survey_send_invitation(osv.osv_memory):
@@ -79,7 +80,7 @@ class survey_send_invitation(osv.osv_memory):
if not report_name or not res_ids:
return (False, Exception('Report name and Resources ids are required !!!'))
try:
ret_file_name = tools.config['addons_path'] + '/survey/report/' + file_name + '.pdf'
ret_file_name = addons.get_module_resource('survey', 'report') + file_name + '.pdf'
service = netsvc.LocalService(report_name);
(result, format) = service.create(cr, uid, res_ids, {}, {})
fp = open(ret_file_name, 'wb+');
@@ -122,7 +123,7 @@ class survey_send_invitation(osv.osv_memory):
new_user.append(use.id)
for id in survey_ref.browse(cr, uid, survey_ids):
report = self.create_report(cr, uid, [id.id], 'report.survey.form', id.title)
file = open(tools.config['addons_path'] + '/survey/report/' + id.title +".pdf")
file = open(addons.get_module_resource('survey', 'report') + id.title +".pdf")
file_data = ""
while 1:
line = file.readline()
@@ -131,7 +132,7 @@ class survey_send_invitation(osv.osv_memory):
break
attachments.append((id.title +".pdf",file_data))
file.close()
os.remove(tools.config['addons_path'] + '/survey/report/' + id.title + ".pdf")
os.remove(addons.get_module_resource('survey', 'report') + id.title +".pdf")
for partner in self.pool.get('res.partner').browse(cr, uid, partner_ids):
for addr in partner.address: