summaryrefslogtreecommitdiff
path: root/addons/base_module_quality/base_module_quality.py
diff options
context:
space:
mode:
authorNajlaâ EL KHAYAT <nel@tinyerp.com>2009-01-09 11:35:45 +0100
committerNajlaâ EL KHAYAT <nel@tinyerp.com>2009-01-09 11:35:45 +0100
commitbdedbedb6271c36eb216df367d35a6e8de07c12d (patch)
tree03caba86457da29175b517cdef5b8103f69eaf67 /addons/base_module_quality/base_module_quality.py
parent02de8a94c797e589b23f2ed0557920a1bde5f324 (diff)
parent74a6e4000e1187e14af2387283f66e9808b04be7 (diff)
merge
bzr revid: nel@tinyerp.com-20090109103545-22glgy373aeohcai
Diffstat (limited to 'addons/base_module_quality/base_module_quality.py')
-rw-r--r--addons/base_module_quality/base_module_quality.py107
1 files changed, 85 insertions, 22 deletions
diff --git a/addons/base_module_quality/base_module_quality.py b/addons/base_module_quality/base_module_quality.py
index 195e345e8ef..4590a51dfe3 100644
--- a/addons/base_module_quality/base_module_quality.py
+++ b/addons/base_module_quality/base_module_quality.py
@@ -2,7 +2,7 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
@@ -19,43 +19,106 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
-
+import pooler
+import os
+import osv
+from tools import config
class abstract_quality_check(object):
'''
- This Class provide...
+ This Class provides...
'''
- #This float have to store the rating of the module.
- #Used to compute the final score (average of all scores).
- score = 0.0
+ def __init__(self):
+ '''
+ this method should initialize the var
+ '''
+ #This float have to store the rating of the module.
+ #Used to compute the final score (average of all scores).
+ #0 <= self.score <= 1
+ self.score = 0.0
- #This char have to store the result.
- #Used to display the result of the test.
- result = ""
+ #This char have to store the name of the test.
+ self.name = ""
- #This char have to store the result with more details.
- #Used to provide more details if necessary.
- result_details = ""
+ #This char have to store the aim of the test and eventually a note.
+ self.note = ""
- #This bool defines if the test can be run only if the module is installed.
- #True => the module have to be installed.
- #False => the module can be uninstalled.
- bool_installed_only = True
+ #This char have to store the result.
+ #Used to display the result of the test.
+ self.result = ""
- def __init__(self):
- '''
- this method should initialize the var
- '''
- raise 'Not Implemented'
+ #This char have to store the result with more details.
+ #Used to provide more details if necessary.
+ self.result_details = ""
+
+ #This bool defines if the test can be run only if the module is installed.
+ #True => the module have to be installed.
+ #False => the module can be uninstalled.
+ self.bool_installed_only = True
+
+ #This variable is use to make result of test should have more weight (Some tests are more critical than others)
+ self.ponderation = 1.0
+
+ #Specify test got an error on module
+ self.error = False
+
+ #The tests have to subscribe itselfs in this list, that contains all the test that have to be performed.
+ self.tests = []
+ self.list_folders = os.listdir(config['addons_path']+'/base_module_quality/')
+ for item in self.list_folders:
+ self.item = item
+ path = config['addons_path']+'/base_module_quality/'+item
+ if os.path.exists(path+'/'+item+'.py') and item not in ['report', 'wizard', 'security']:
+ item2 = 'base_module_quality.' + item +'.' + item
+ x = __import__(item2)
+ x2 = getattr(x, item)
+ x3 = getattr(x2, item)
+ self.tests.append(x3)
+# raise 'Not Implemented'
def run_test(self, cr, uid, module_path=""):
'''
this method should do the test and fill the score, result and result_details var
'''
- raise 'Not Implemented'
+ raise osv.except_osv(_('Programming Error'), _('Test Is Not Implemented'))
+
+ def get_objects(self, cr, uid, module):
+ # This function returns all object of the given module..
+ pool = pooler.get_pool(cr.dbname)
+ ids2 = pool.get('ir.model.data').search(cr, uid, [('module','=', module), ('model','=','ir.model')])
+ model_list = []
+ model_data = pool.get('ir.model.data').browse(cr, uid, ids2)
+ for model in model_data:
+ model_list.append(model.res_id)
+ obj_list = []
+ for mod in pool.get('ir.model').browse(cr, uid, model_list):
+ obj_list.append(str(mod.model))
+ return obj_list
+
+ def get_ids(self, cr, uid, object_list):
+ #This method return dictionary with ids of records of object for module
+ pool = pooler.get_pool(cr.dbname)
+ result_ids = {}
+ for obj in object_list:
+ ids = pool.get(obj).search(cr, uid, [])
+ result_ids[obj] = ids
+ return result_ids
+
+ def format_table(self, header=[], data_list=[]):
+ detail = ""
+ detail += (header[0]) % tuple(header[1])
+ frow = '\n|-'
+ for i in header[1]:
+ frow += '\n| %s'
+ for key, value in data_list.items():
+ detail += (frow) % tuple(value)
+ detail = detail + '\n|}'
+ return detail
+ def add_quatation(self, x, y):
+ return x/y
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: