base module quality

bzr revid: mra@tinyerp.com-20081224135131-7keeqeyqf168g5e1
This commit is contained in:
mra (Open ERP) 2008-12-24 19:21:31 +05:30
parent a5d8cf5d2c
commit dfb4a39b6b
6 changed files with 33 additions and 27 deletions

View File

@ -34,7 +34,7 @@ This module's aim is to check the quality of other modules.
""",
"init_xml" : [],
"update_xml" : ["base_module_quality_wizard.xml"],
"update_xml" : ["base_module_quality_wizard.xml", "security/ir.model.access.csv",],
"category" : "Tiny Specific Modules/Base module quality",
"active": False,
"installable": True

View File

@ -19,7 +19,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import pooler
class abstract_quality_check(object):
'''
@ -41,11 +41,11 @@ class abstract_quality_check(object):
#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
bool_installed_only = True
def __init__(self):
'''
this method should initialize the var
this method should initialize the var
'''
raise 'Not Implemented'
@ -55,7 +55,27 @@ class abstract_quality_check(object):
'''
raise '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
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -16,7 +16,7 @@
</record>
<act_window
id="act_view_wiz_quality_check"
name="Wizard Quality Check"
name="Quality Check"
res_model="wizard.quality.check"
src_model="ir.module.module"
target="new"

View File

@ -42,15 +42,8 @@ This test checks if the module classes are raising exception when calling basic
def run_test(self, cr, uid, module_path):
pool = pooler.get_pool(cr.dbname)
module_name = module_path.split('/')[-1]
ids2 = pool.get('ir.model.data').search(cr, uid, [('module','=', module_name), ('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))
result={}
obj_list = self.get_objects(cr, uid, module_name)
result = {}
ok_count = 0
ex_count = 0

View File

@ -0,0 +1,2 @@
"id","name","model_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_wizard_quality_check","wizard.quality.check","model_wizard_quality_check",1,1,1,1
1 id name model_id:id perm_read perm_write perm_create perm_unlink
2 access_wizard_quality_check wizard.quality.check model_wizard_quality_check 1 1 1 1

View File

@ -47,20 +47,13 @@ This test checks the speed of the module.
pool = pooler.get_pool(cr.dbname)
module_name = module_path.split('/')[-1]
self.result+=('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-10s \n! %-10s \n! %-10s \n! %-10s \n! %-20s') % ('Object Name'.ljust(40), 'Size (S)'.ljust(10), '1'.ljust(10), 'S/2'.ljust(10), 'S'.ljust(10), 'Complexity'.ljust(20))
ids2 = pool.get('ir.model.data').search(cr, uid, [('module','=', module_name), ('model','=','ir.model')])
model_data = pool.get('ir.model.data').browse(cr, uid, ids2)
model_list = []
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))
obj_list = self.get_objects(cr, uid, module_name)
obj_counter = 0
score = 0
for obj in obj_list:
obj_ids = self.get_ids(cr, uid, obj_list)
for obj in obj_ids:
obj_counter += 1
ids = pool.get(obj).search(cr, uid, [])
ids = obj_ids[obj]
ids = ids[:100]
size = len(ids)
if size:
@ -68,12 +61,10 @@ This test checks the speed of the module.
pool.get(obj).read(cr, uid, ids[0])
c2 = time.time()
base_time = c2 - c1
c1 = time.time()
pool.get(obj).read(cr, uid, ids[:size/2])
c2 = time.time()
halfsize_time = c2 - c1
c1 = time.time()
pool.get(obj).read(cr, uid, ids)
c2 = time.time()