1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
24 from tools import config
26 class abstract_quality_check(object):
33 this method should initialize the var
35 #This float have to store the rating of the module.
36 #Used to compute the final score (average of all scores).
40 #This char have to store the name of the test.
43 #This char have to store the result.
44 #Used to display the result of the test.
47 #This char have to store the result with more details.
48 #Used to provide more details if necessary.
49 self.result_details = ""
51 #This bool defines if the test can be run only if the module is installed.
52 #True => the module have to be installed.
53 #False => the module can be uninstalled.
54 self.bool_installed_only = True
56 #This variable is use to make result of test should have more weight (Some tests are more critical than others)
57 self.ponderation = 1.0
59 #Specify test got an error on module
62 #The tests have to subscribe itselfs in this list, that contains all the test that have to be performed.
64 self.list_folders = os.listdir(config['addons_path']+'/base_module_quality/')
65 for item in self.list_folders:
67 path = config['addons_path']+'/base_module_quality/'+item
68 if os.path.exists(path+'/'+item+'.py') and item not in ['report', 'wizard', 'security']:
69 item2 = 'base_module_quality.' + item +'.' + item
72 x3 = getattr(x2, item)
74 # raise 'Not Implemented'
76 def run_test(self, cr, uid, module_path=""):
78 this method should do the test and fill the score, result and result_details var
80 raise 'Not Implemented'
82 def get_objects(self, cr, uid, module):
83 # This function returns all object of the given module..
84 pool = pooler.get_pool(cr.dbname)
85 ids2 = pool.get('ir.model.data').search(cr, uid, [('module','=', module), ('model','=','ir.model')])
87 model_data = pool.get('ir.model.data').browse(cr, uid, ids2)
88 for model in model_data:
89 model_list.append(model.res_id)
91 for mod in pool.get('ir.model').browse(cr, uid, model_list):
92 obj_list.append(str(mod.model))
95 def get_ids(self, cr, uid, object_list):
96 #This method return dictionary with ids of records of object for module
97 pool = pooler.get_pool(cr.dbname)
99 for obj in object_list:
100 ids = pool.get(obj).search(cr, uid, [])
101 result_ids[obj] = ids
104 def format_table(self, header=[], data_list=[]):
108 for head in data_list[1]:
109 header_list.append(head)
110 detail += (header[0]) % tuple(header_list)
111 for res in data_list[0]:
112 data_list[0][res].append(res)
113 detail += (header[1]) % tuple(data_list[0][res])
114 detail = detail + '\n|}'
117 def add_quatation(self, x, y):
120 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: