From b681cb426165a2fc75230d195d7c0605b50ab7cd Mon Sep 17 00:00:00 2001 From: "uco (OpenERP)" Date: Tue, 26 Oct 2010 18:52:54 +0530 Subject: [PATCH 01/12] [FIX] : Removed tools.config['addons_path'] for bug 666714. lp bug: https://launchpad.net/bugs/666714 fixed bzr revid: uco@tinyerp.com-20101026132254-5gkcrrxaskc3aczf --- addons/base_module_doc_rst/base_module_doc_rst.py | 3 ++- addons/base_module_quality/unit_test/unit_test.py | 4 ++-- addons/hr/hr.py | 4 ++-- addons/outlook/installer.py | 4 ++-- addons/report_webkit/webkit_report.py | 4 ++-- addons/survey/wizard/survey_answer.py | 8 ++++---- addons/survey/wizard/survey_send_invitation.py | 7 ++++--- 7 files changed, 18 insertions(+), 16 deletions(-) diff --git a/addons/base_module_doc_rst/base_module_doc_rst.py b/addons/base_module_doc_rst/base_module_doc_rst.py index c7671a62bd4..9d86a191177 100755 --- a/addons/base_module_doc_rst/base_module_doc_rst.py +++ b/addons/base_module_doc_rst/base_module_doc_rst.py @@ -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,) diff --git a/addons/base_module_quality/unit_test/unit_test.py b/addons/base_module_quality/unit_test/unit_test.py index 598d443382f..c92ba6ddeac 100644 --- a/addons/base_module_quality/unit_test/unit_test.py +++ b/addons/base_module_quality/unit_test/unit_test.py @@ -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 diff --git a/addons/hr/hr.py b/addons/hr/hr.py index 3c65e79f11f..724f8b494fc 100644 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -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 = { diff --git a/addons/outlook/installer.py b/addons/outlook/installer.py index 1fe408d7e67..0f71b6c33dc 100755 --- a/addons/outlook/installer.py +++ b/addons/outlook/installer.py @@ -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 diff --git a/addons/report_webkit/webkit_report.py b/addons/report_webkit/webkit_report.py index 3dd768128fb..c95a9ce5e2e 100644 --- a/addons/report_webkit/webkit_report.py +++ b/addons/report_webkit/webkit_report.py @@ -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 : diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index 109f4509d81..69cb0da2023 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -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(); diff --git a/addons/survey/wizard/survey_send_invitation.py b/addons/survey/wizard/survey_send_invitation.py index 92ba965d880..8c61a9b4393 100644 --- a/addons/survey/wizard/survey_send_invitation.py +++ b/addons/survey/wizard/survey_send_invitation.py @@ -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: From 979055362f8c3691e4f1a856e4d297444f647a20 Mon Sep 17 00:00:00 2001 From: "uco (OpenERP)" Date: Wed, 27 Oct 2010 12:28:54 +0530 Subject: [PATCH 02/12] [FIX] project_planning: Corrected 'File not found' error for --log-level=test. bzr revid: uco@tinyerp.com-20101027065854-hkltmzi8jahcmqfm --- addons/project_planning/__openerp__.py | 4 ++-- ...oject_plannning_report.yml => project_planning_report.yml} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename addons/project_planning/test/{project_plannning_report.yml => project_planning_report.yml} (100%) diff --git a/addons/project_planning/__openerp__.py b/addons/project_planning/__openerp__.py index 3f378cc21be..1815582e1bf 100644 --- a/addons/project_planning/__openerp__.py +++ b/addons/project_planning/__openerp__.py @@ -54,8 +54,8 @@ At the end of the month, the planning manager can also check if the encoded time 'project_planning_demo.xml', ], 'test': [ - 'test/planning_states.yml' - 'test/planning_report.yml' + 'test/planning_states.yml', + 'test/project_planning_report.yml' ], 'installable': True, 'active': False, diff --git a/addons/project_planning/test/project_plannning_report.yml b/addons/project_planning/test/project_planning_report.yml similarity index 100% rename from addons/project_planning/test/project_plannning_report.yml rename to addons/project_planning/test/project_planning_report.yml From 5640c5b96b96785c99c228a74009cea4ad7c6b9a Mon Sep 17 00:00:00 2001 From: "uco (OpenERP)" Date: Wed, 27 Oct 2010 12:33:24 +0530 Subject: [PATCH 03/12] [FIX] hr_timesheet_sheet, project_timesheet: Corrected typo. bzr revid: uco@tinyerp.com-20101027070324-akahll2obchnn8fi --- addons/hr_timesheet_sheet/wizard/hr_timesheet_current_view.xml | 2 +- addons/project_timesheet/project_timesheet_view.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/hr_timesheet_sheet/wizard/hr_timesheet_current_view.xml b/addons/hr_timesheet_sheet/wizard/hr_timesheet_current_view.xml index fe63a4ce7b3..2c87df69757 100644 --- a/addons/hr_timesheet_sheet/wizard/hr_timesheet_current_view.xml +++ b/addons/hr_timesheet_sheet/wizard/hr_timesheet_current_view.xml @@ -7,7 +7,7 @@ form
- +