bzr revid: fp@tinyerp.com-20090105225509-ovzgto6jz2ihuss2
This commit is contained in:
Fabien Pinckaers 2009-01-05 23:55:09 +01:00
commit 0ceda3985f
9 changed files with 246 additions and 283 deletions

View File

@ -1594,7 +1594,7 @@ class account_config_wizard(osv.osv_memory):
ids=module_obj.search(cr, uid, [('category_id', '=', 'Account Charts'), ('state', '<>', 'installed')])
res=[(m.id, m.shortdesc) for m in module_obj.browse(cr, uid, ids)]
res.append((-1, 'None'))
res.sort(lambda x,y: cmp(x[1],y[1]))
res.sort(key=lambda x: x[1])
return res
_columns = {
@ -1621,25 +1621,12 @@ class account_config_wizard(osv.osv_memory):
'target':'new',
}
def install_account_chart(self, cr, uid,ids, context=None):
def install_account_chart(self, cr, uid, ids, context=None):
for res in self.read(cr,uid,ids):
id = res['charts']
def install(id):
chart_id = res['charts']
if chart_id > 0:
mod_obj = self.pool.get('ir.module.module')
mod_obj.write(cr , uid, [id] ,{'state' : 'to install'})
mod_obj.download(cr, uid, [id], context=context)
cr.commit()
cr.execute("select m.id as id from ir_module_module_dependency d inner join ir_module_module m on (m.name=d.name) where d.module_id=%s and m.state='uninstalled'",(id,))
ret = cr.fetchall()
if len(ret):
for r in ret:
install(r[0])
else:
mod_obj.write(cr , uid, [id] ,{'state' : 'to install'})
mod_obj.download(cr, uid, [id], context=context)
cr.commit()
if id>0:
install(id)
mod_obj.button_install(cr, uid, [chart_id], context=context)
cr.commit()
db, pool = pooler.restart_pool(cr.dbname, update_module=True)

View File

@ -28,31 +28,18 @@ class abstract_quality_check(object):
This Class provide...
'''
# #This float have to store the rating of the module.
# #Used to compute the final score (average of all scores).
# 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 result with more details.
# #Used to provide more details if necessary.
# 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.
# bool_installed_only = True
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 name of the test.
self.name = ""
#This char have to store the result.
#Used to display the result of the test.
self.result = ""
@ -66,13 +53,13 @@ class abstract_quality_check(object):
#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 = 0.0
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:
@ -86,11 +73,11 @@ class abstract_quality_check(object):
self.tests.append(x3)
# raise 'Not Implemented'
def run_test(self, cr, uid, module_path="", module_state=""):
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 'Not Implemented'
def get_objects(self, cr, uid, module):
# This function returns all object of the given module..
@ -114,40 +101,22 @@ class abstract_quality_check(object):
result_ids[obj] = ids
return result_ids
def format_table(self, test='', header=[], data_list=[]):
res_format = {}
if test=='method':
detail = ""
detail += "\n===Method Test===\n"
res_format['detail'] = detail
if not data_list[2]:
detail += ('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-16s \n! %-20s \n! %-16s ') % (header[0].ljust(40), header[1].ljust(16), header[2].ljust(20), header[3].ljust(16))
for res in data_list[1]:
detail += ('\n|-\n| %s \n| %s \n| %s \n| %s ') % (res, data_list[1][res][0], data_list[1][res][1], data_list[1][res][2])
res_format['detail'] = detail + '\n|}'
res_format['summary'] = data_list[0]
elif test=='pylint':
res_format['summary'] = data_list[0]
res_format['detail'] = data_list[1]
elif test=='speed':
detail = ""
detail += "\n===Speed Test===\n"
res_format['detail'] = detail
if not data_list[2]:
detail += ('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-10s \n! %-10s \n! %-10s \n! %-10s \n! %-20s') % (header[0].ljust(40), header[1].ljust(10), header[2].ljust(10), header[3].ljust(10), header[4].ljust(10), header[5].ljust(20))
for data in data_list[1]:
detail += ('\n|-\n| %s \n| %s \n| %s \n| %s \n| %s \n| %s ') % (data[0], data[1], data[2], data[3], data[4], data[5])
res_format['detail'] = detail + '\n|}\n'
res_format['summary'] = data_list[0]
elif test=='terp':
res_format['summary'] = data_list[0]
res_format['detail'] = data_list[1]
return res_format
def format_table(self, header=[], data_list=[]):
detail = ""
if header[0]=='method':
detail += ('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-16s \n! %-20s \n! %-16s ') % (header[1].ljust(40), header[2].ljust(16), header[3].ljust(20), header[4].ljust(16))
for res in data_list[0]:
detail += ('\n|-\n| %s \n| %s \n| %s \n| %s ') % (res, data_list[0][res][0], data_list[0][res][1], data_list[0][res][2])
detail = detail + '\n|}'
elif header[0]=='speed':
detail += ('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-10s \n! %-10s \n! %-10s \n! %-10s \n! %-20s') % (header[1].ljust(40), header[2].ljust(10), header[3].ljust(10), header[4].ljust(10), header[5].ljust(10), header[6].ljust(20))
for data in data_list[0]:
detail += ('\n|-\n| %s \n| %s \n| %s \n| %s \n| %s \n| %s ') % (data[0], data[1], data[2], data[3], data[4], data[5])
detail = detail + '\n|}\n'
return detail
def add_quatation(self, x, y):
return x/y
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -3,46 +3,71 @@
<data>
<!--<wizard id="base_module_quality" model="ir.module.module" name="base.module.quality" string="Check the Quality of module"/>-->
<record id="view_wizard_quality_check" model="ir.ui.view">
<record id="view_wizard_quality_check_tree" model="ir.ui.view">
<field name="name">Results of Quality Checks</field>
<field name="model">wizard.quality.check</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Result">
<field name="name"/>
<field name="final_score"/>
</tree>
</field>
</record>
<record id="view_wizard_quality_check_form" model="ir.ui.view">
<field name="name">Results of Quality Checks</field>
<field name="model">wizard.quality.check</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Result">
<notebook>
<page string="Verbose detail">
<field name="verbose_detail" string="Verbose detail" nolabel="1" colspan="4" height="350" width="800"/>
</page>
</notebook>
<field name="name" nolabel="1" readonly="1"/>
<field name="final_score" nolabel="1" readonly="1"/>
<separator colspan="4" string="Tests"/>
<field name="test_ids" nolabel="1" colspan="4" height="350" width="800" readonly="1"/>
</form>
</field>
</record>
<record id="view_wizard_quality_detail" model="ir.ui.view">
<record id="view_wizard_quality_detail_form" model="ir.ui.view">
<field name="name">Results of Quality Checks with detail</field>
<field name="model">quality.check.detail</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Result">
<notebook>
<page string="Summary">
<field name="general_info" widget="text_wiki" nolabel="1" colspan="4" height="350" width="800"/>
</page>
<page string="Detail">
<field name="detail" widget="text_wiki" nolabel="1" colspan="4" height="350" width="800"/>
</page>
</notebook>
<page string="Summary">
<field name="name" readonly="1"/>
<field name="score" readonly="1"/>
<field name="ponderation" readonly="1"/>
<field name="summary" widget="text_wiki" nolabel="1" colspan="4" height="350" width="800" readonly="1"/>
</page>
<page string="Detail">
<field name="detail" widget="text_wiki" nolabel="1" colspan="4" readonly="1"/>
</page>
</notebook>
</form>
</field>
</record>
<act_window
id="act_view_wiz_quality_check"
name="Quality Check"
res_model="wizard.quality.check"
src_model="ir.module.module"
target="new"
view_mode="form"
context="{'module_id': active_id}"
/>
<record id="view_wizard_quality_detail_tree" model="ir.ui.view">
<field name="name">Results of Quality Checks with detail</field>
<field name="model">quality.check.detail</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Result">
<field name="name"/>
<field name="score"/>
<field name="ponderation"/>
</tree>
</field>
</record>
<wizard string="Quality Check"
model="ir.module.module"
name="create_quality_check_wiz"
id="create_quality_check_id"
menu="True"/>
</data>
</openerp>

View File

@ -31,21 +31,15 @@ class quality_test(base_module_quality.abstract_quality_check):
def __init__(self):
super(quality_test, self).__init__()
# self.result = """
#===Method Test===:
#
#This test checks if the module classes are raising exception when calling basic methods or no.
#
#"""
self.bool_installed_only = True
self.ponderation = 1.0
self.result_det = {}
return None
def run_test(self, cr, uid, module_path, module_state):
def run_test(self, cr, uid, module_path):
pool = pooler.get_pool(cr.dbname)
module_name = module_path.split('/')[-1]
obj_list = self.get_objects(cr, uid, module_name)
result = {}
ok_count = 0
ex_count = 0
for obj in obj_list:
@ -71,29 +65,29 @@ class quality_test(base_module_quality.abstract_quality_check):
except:
temp.append('Exception')
ex_count += 1
result[obj] = temp
# self.result += ('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-16s \n! %-20s \n! %-16s ') % ('Object Name'.ljust(40), 'search()'.ljust(16), 'fields_view_get()'.ljust(20), 'read()'.ljust(16))
header_list = ['Object Name', 'search()', 'fields_view_get', 'read']
# for res in result:
# self.result += ('\n|-\n| %s \n| %s \n| %s \n| %s ') % (res, result[res][0],result[res][1], result[res][2])
# self.result += '\n|}'
self.result_det[obj] = temp
self.score = (ok_count + ex_count) and float(ok_count)/float(ok_count + ex_count) or 0.0
if not self.bool_installed_only or module_state=="installed":
summary = """
self.result = self.get_result()
self.result_details = self.get_result_details()
return None
def get_result(self):
summary = """
===Method Test===:
This test checks if the module classes are raising exception when calling basic methods or no.
""" #+ "Score: " + str(self.score) + "/10\n"
else:
summary =""" \n===Method Test===:
The module has to be installed before running this test.\n\n """
header_list = ""
self.error = True
self.result = self.format_table(test='method', header=header_list, data_list=[summary,result,self.error])
return None
""" + "Score: " + str(self.score) + "/10\n"
return summary
def get_result_details(self):
header_list = ['method', 'Object Name', 'search()', 'fields_view_get', 'read']
detail = "\n===Method Test===\n"
if not self.error:
detail += self.format_table(header=header_list, data_list=[self.result_det])
return detail
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -31,17 +31,12 @@ class quality_test(base_module_quality.abstract_quality_check):
def __init__(self):
super(quality_test, self).__init__()
# self.result = """
#===Pylint Test===:
#
# This test checks if the module satisfy the current coding standard used by OpenERP.
#
#"""
self.name = _("Pylint Test")
self.bool_installed_only = False
self.ponderation = 1.0
return None
def run_test(self, cr, uid, module_path, module_state):
def run_test(self, cr, uid, module_path):
config_file_path = config['addons_path']+'/base_module_quality/pylint_test/pylint_test_config.txt'
list_files = os.listdir(module_path)
for i in list_files:
@ -52,12 +47,14 @@ class quality_test(base_module_quality.abstract_quality_check):
n = 0
score = 0.0
detail = ""
detail = "\n===Pylint Test===\n"
for file in list_files:
if file.split('.')[-1] == 'py' and not file.endswith('__init__.py') and not file.endswith('__terp__.py'):
file_path = os.path.join(module_path, file)
res = os.popen('pylint --rcfile=' + config_file_path + ' ' + file_path).read()
try:
res = os.popen('pylint --rcfile=' + config_file_path + ' ' + file_path).read()
except:
self.result += _("Error. Is pylint correctly installed?")+"\n"
break
n += 1
leftchar = -1
while res[leftchar:leftchar+1] != ' ' and leftchar-1 <= 0:
@ -65,33 +62,38 @@ class quality_test(base_module_quality.abstract_quality_check):
rightchar = -10
while res[rightchar:rightchar+1] != '/' and rightchar+1 <= 0:
rightchar += 1
try:
score += float(res[leftchar+1:rightchar])
# self.result += file + ": " + res[leftchar+1:rightchar] + "/10\n"
detail += file + ": " + res[leftchar+1:rightchar] + "/10\n"
self.result += file + ": " + res[leftchar+1:rightchar] + "/10\n"
except:
score += 0
# self.result += file + ": Unable to parse the result. Check the details.\n"
detail += file + ": Unable to parse the result. Check the details.\n"
self.result += file + ": "+_("Unable to parse the result. Check the details.")+"\n"
self.result_details += res
self.score = n and score / n or score
average_score = n and score / n or score
self.score = (average_score + 10) /20
return None
def get_result(self, cr, uid, module_path):
self.run_test(cr, uid, module_path)
if not self.bool_installed_only or module_state=="installed":
summary ="""
===Pylint Test===:
This test checks if the module satisfies the current coding standard used by OpenERP.
""" #+ "Score: " + str(self.score) + "/10\n"
""" + "Score: " + str(self.score) + "/10\n"
else:
summary =""" \n===Pylint Test===:
The module has to be installed before running this test.\n\n """
header_list = ""
self.error = True
self.result = self.format_table(test='pylint', data_list=[summary,detail,self.error])
return None
return summary
def get_result_details(self):
detail = "\n===Pylint Test===\n" + self.result
return detail
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -35,26 +35,17 @@ class quality_test(base_module_quality.abstract_quality_check):
def __init__(self):
super(quality_test, self).__init__()
# self.result = """
#===Speed Test===:
#
#This test checks the speed of the module.
#
#"""
self.bool_installed_only = True
self.ponderation = 1.0
self.listdata = []
return None
def run_test(self, cr, uid, module_path, module_state):
def run_test(self, cr, uid, module_path):
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-Number of Records (S)'.ljust(10), '1'.ljust(10), 'S/2'.ljust(10), 'S'.ljust(10), 'Complexity using query'.ljust(20))
header_list = ['Object Name', 'Size-Number of Records (S)', '1', 'S/2', 'S', 'Complexity using query']
obj_list = self.get_objects(cr, uid, module_name)
obj_counter = 0
score = 0
obj_ids = self.get_ids(cr, uid, obj_list)
detail = ""
list1 = []
for obj in obj_ids:
obj_counter += 1
ids = obj_ids[obj]
@ -77,9 +68,8 @@ class quality_test(base_module_quality.abstract_quality_check):
if size < 5:
self.score += -2
# self.result += ('\n|-\n| %s \n| %s \n| %s \n| %s \n| %s \n| %s ') % (obj, size, code_base_complexity, code_half_complexity, code_size_complexity, "Warning! Not enough demo data")
list = [obj, size, code_base_complexity, code_half_complexity, code_size_complexity, "Warning! Not enough demo data"]
list1.append(list)
self.listdata.append(list)
else:
if code_size_complexity <= (code_base_complexity + size):
complexity = "O(1)"
@ -87,31 +77,39 @@ class quality_test(base_module_quality.abstract_quality_check):
else:
complexity = "O(n) or worst"
score = 0
# self.result += ('\n|-\n| %s \n| %s \n| %s \n| %s \n| %s \n| %s ') % (obj, size, code_base_complexity, code_half_complexity, code_size_complexity, complexity)
list = [obj, size, code_base_complexity, code_half_complexity, code_size_complexity, complexity]
list1.append(list)
self.listdata.append(list)
else:
score += -5
# self.result += ('\n|-\n| %s \n| %s \n| %s \n| %s \n| %s \n| %s ') % (obj, size, "", "", "", "Warning! Object has no demo data")
list = [obj, size, "", "", "", "Warning! Object has no demo data"]
list1.append(list)
# self.result += '\n|}\n'
self.listdata.append(list)
self.score = obj_counter and score/obj_counter or 0.0
return None
def get_result(self, cr, uid, module_path, module_state):
self.run_test(cr, uid, module_path)
if not self.bool_installed_only or module_state=="installed":
summary = """
===Speed Test===:
This test checks the speed of the module.
"""#+ "Score: " + str(self.score) + "/10\n"
""" + "Score: " + str(self.score) + "/10\n"
else:
summary =""" \n===Speed Test===:
The module has to be installed before running this test.\n\n """
header_list = ""
self.error = True
self.result = self.format_table(test='speed', header=header_list, data_list=[summary,list1,self.error])
return None
return summary
def get_result_detail(self):
header_list = ['speed', 'Object Name', 'Size-Number of Records (S)', '1', 'S/2', 'S', 'Complexity using query']
detail = ""
detail += "\n===Speed Test===\n"
if not self.error:
detail += self.format_table(header=header_list, data_list=[self.listdata])
return detail
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -34,11 +34,13 @@ class quality_test(base_module_quality.abstract_quality_check):
This test checks the quality of __terp__.py file in the selected module.
'''
super(quality_test, self).__init__()
self.bool_installed_only = True
self.bool_installed_only = False
self.no_terp = False
self.ponderation = 2
return None
def run_test(self, cr, uid, module_path, module_state):
no_terp = False
def run_test(self, cr, uid, module_path):
list_files = os.listdir(module_path)
for i in list_files:
path = os.path.join(module_path, i)
@ -50,20 +52,8 @@ class quality_test(base_module_quality.abstract_quality_check):
score = 0.0
feel_good_factor = 0
feel_bad_factor = 0
detail = "\n===TERP Test===\n"
summary = "\n===TERP Test===:\n"
if '__terp__.py' not in list_files:
no_terp = True
if no_terp:
summary += """
The module does not contain the __terp__.py file.\n\n """
header_list = ""
self.error = True
self.result = self.format_table(test='terp', data_list=[summary, detail, self.error])
return None
self.no_terp = True
terp_file = os.path.join(module_path,'__terp__.py')
res = eval(tools.file_open(terp_file).read())
@ -88,21 +78,26 @@ The module does not contain the __terp__.py file.\n\n """
else:
feel_bad_factor += 1
self.score = round((feel_good_factor * 10) / float(feel_good_factor + feel_bad_factor),2)
# if not self.bool_installed_only or module_state=="installed":
summary += """
This test checks if the module satisfies the current coding standard for __terp__.py file used by OpenERP.
"""
# else:
# summary += """
#The module has to be installed before running this test.\n\n """
# header_list = ""
# error = True
detail += "__terp__.py : "+ str(self.score) + "/10\n"
self.result = self.format_table(test='terp', data_list=[summary, detail, self.error])
self.score = round((feel_good_factor) / float(feel_good_factor + feel_bad_factor),2)
self.result += "__terp__.py : "+ str(self.score) + "/10\n"
return None
def get_result(self, cr, uid, module_path, module_state):
self.run_test(cr, uid, module_path)
summary = "\n===TERP Test===:\n"
if self.no_terp:
summary += """
The module does not contain the __terp__.py file.\n\n """
else:
summary += """
This test checks if the module satisfies the current coding standard for __terp__.py file used by OpenERP.
""" + "Score: " + str(self.score) + "/10\n"
return summary
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
def get_result_details(self):
detail = "\n===TERP Test===\n" + self.result
return detail
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -27,108 +27,99 @@ import tools
import os
from base_module_quality import base_module_quality
#TODO: (utiliser les nouveaux wizards pour heriter la vue et rajouter un onglet par test?)
#TODO: implement the speed test
#TODO: add cheks: do the class quality_check inherits the class abstract_quality_check?
#TODO: improve translability
#TODO: clean
#To keep or not? to be discussed...
#~ view_form = """<?xml version="1.0"?>
#~ <form string="Check quality">
#~ <notebook>
#~ <page string="Summary">
#~ <field name="general_info" widget="text_wiki" nolabel="1" colspan="4" height="350" width="800"/>
#~ </page>
#~ </notebook>
#~ </form>"""
#~ view_field = {
#~ "general_info": {'type': 'text', 'string': 'General Info', 'readonly':True},
#~ }
class wiz_quality_check(osv.osv_memory):
# general_info = ""
class wiz_quality_check(osv.osv):
_name = 'wizard.quality.check'
def _check(self, cr, uid, data, context={}):
string_ret = ""
string_detail = ""
from tools import config
data['ids'] = data.get('module_id', False)
pool = pooler.get_pool(cr.dbname)
module_data = pool.get('ir.module.module').browse(cr, uid, [data['ids']])
list_folders = os.listdir(config['addons_path']+'/base_module_quality/')
module_name = module_data[0].name
abstract_obj = base_module_quality.abstract_quality_check()
score_sum = 0.0
ponderation_sum = 0.0
final_score = ""
for test in abstract_obj.tests:
ad = tools.config['addons_path']
if module_data[0].name == 'base':
ad = tools.config['root_path']+'/addons'
module_path = os.path.join(ad, module_data[0].name)
val = test.quality_test()
val.run_test(cr, uid, str(module_path), str(module_data[0].state))
string_ret += val.result['summary'] #summary tab
if not val.error:
string_ret += "Score: " + str(val.score) + "/10\n" #val.score = val.score * val.ponderation ???
string_detail += val.result['detail'] # detail tab
score_sum += (val.add_quatation(val.score, 10) * val.ponderation)
ponderation_sum += val.ponderation
final_score = str(score_sum / ponderation_sum * 100) + "%"
string_ret += "\n\nPonderation Result for module:" + final_score
self.string_detail = string_detail
return ""
def _check_detail(self, cr, uid, data, context={}):
return self.string_detail
# def _general_info(self, cr, uid, data, context={}):
# return self.general_info
#~ states = {
#~ 'init': {
#~ 'actions': [_check],
#~ 'result': {'type':'form', 'arch':view_form, 'fields':view_field, 'state':[('end','Ok')]},
#~ },
#~ }
#To keep or not? to be discussed...
#~ 'init': {
#~ 'actions': [],
#~ 'result': {'type':'form', 'arch':form_check, 'fields':fields_check, 'state':[('end','Cancel'),('do','Do Test')]}
#~ },
_columns = {
# 'general_info': fields.text('General Info', readonly="1",),
# 'detail' : fields.text('Detail', readonly="0",),
'verbose_detail' : fields.one2many('quality.check.detail', 'quality_check', 'Verbose Detail', readonly="0",)
'name': fields.char('Rated Module', size=64, ),
'final_score': fields.char('Final Score', size=10,),
'test_ids' : fields.one2many('quality.check.detail', 'quality_check_id', 'Test Details',)
}
_defaults = {
# 'general_info': _check,
# 'detail': _check_detail
'verbose_detail': _check,
}
wiz_quality_check()
class quality_check_detail(osv.osv_memory):
class quality_check_detail(osv.osv):
_name = 'quality.check.detail'
_rec_name = 'quality_check'
_columns = {
'quality_check': fields.many2one('wizard.quality.check', 'Quality'),
'general_info': fields.text('General Info', readonly="1",),
'detail' : fields.text('Detail', readonly="1",),
'quality_check_id': fields.many2one('wizard.quality.check', 'Quality'),
'name': fields.char('Name',size=128,),
'score': fields.float('Score',),
'ponderation': fields.float('Ponderation',),
'summary': fields.text('Summary',),
'detail' : fields.text('Details',),
}
quality_check_detail()
class create_quality_check(wizard.interface):
def _create_quality_check(self, cr, uid, data, context={}):
pool = pooler.get_pool(cr.dbname)
if data['id']:
module_data = pool.get('ir.module.module').browse(cr, uid, [data['id']])[0]
#list_folders = os.listdir(config['addons_path']+'/base_module_quality/')
abstract_obj = base_module_quality.abstract_quality_check()
score_sum = 0.0
ponderation_sum = 0.0
create_ids = []
for test in abstract_obj.tests:
ad = tools.config['addons_path']
if module_data.name == 'base':
ad = tools.config['root_path']+'/addons'
module_path = os.path.join(ad, module_data.name)
val = test.quality_test()
if not val.bool_installed_only or module_data.state=="installed":
val.run_test(cr, uid, str(module_path))
data = {
'name': val.name,
'score': val.score,
'ponderation': val.ponderation,
'summary': val.result,
'detail': val.result_details,
}
create_ids.append((0,0,data))
score_sum += val.score * val.ponderation
ponderation_sum += val.ponderation
else:
data = {
'name': val.name,
'score': 0,
'summary': _("The module has to be installed before running this test.")
}
create_ids.append((0,0,data))
final_score = str(score_sum / ponderation_sum * 100) + "%"
data = {
'name': module_data.name,
'final_score': final_score,
'test_ids' : create_ids,
}
obj = pool.get('wizard.quality.check').create(cr, uid, data, context)
return obj
def _open_quality_check(self, cr, uid, data, context):
obj_id = self._create_quality_check(cr, uid, data, context)
return {
'domain': "[('id','=', "+ str(obj_id)+")]",
'name': _('Quality Check'),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'wizard.quality.check',
'type': 'ir.actions.act_window'
}
states = {
'init' : {
'actions' : [],
'result': {'type':'action', 'action':_open_quality_check, 'state':'end'}
}
}
create_quality_check("create_quality_check_wiz")
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
@ -41,7 +41,9 @@ ICS_TAGS = {
'attendee':'multiple',
'location':'normal',
'categories': 'normal',
'description':'normal'
'description':'normal',
# TODO: handle the 'duration' property
}
class document_directory_ics_fields(osv.osv):
@ -126,8 +128,6 @@ class document_directory_content(osv.osv):
if len(dt)==10:
dt = dt+' 09:00:00'
value = datetime.datetime.strptime(dt, '%Y-%m-%d %H:%M:%S')
if field.name=='dtend':
value += datetime.timedelta(hours=3)
event.add(field.name).value = value
s= StringIO.StringIO(cal.serialize().encode('utf8'))
s.name = node
@ -142,3 +142,5 @@ class crm_case(osv.osv):
}
crm_case()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: