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 osv import osv, fields
29
from base_module_quality import base_module_quality
31
#TODO: add cheks: do the class quality_check inherits the class abstract_quality_check?
34
class wiz_quality_check(osv.osv):
35
_name = 'wizard.quality.check'
37
'name': fields.char('Rated Module', size=64, ),
38
'final_score': fields.char('Final Score (%)', size=10,),
39
'test_ids' : fields.one2many('quality.check.detail', 'quality_check_id', 'Tests',)
44
class quality_check_detail(osv.osv):
45
_name = 'quality.check.detail'
47
'quality_check_id': fields.many2one('wizard.quality.check', 'Quality'),
48
'name': fields.char('Name',size=128,),
49
'score': fields.float('Score (%)',),
50
'ponderation': fields.float('Ponderation',help='Some tests are more critical than others, so they have a bigger weight in the computation of final rating'),
51
'note': fields.text('Note',),
52
'summary': fields.text('Summary',),
53
'detail' : fields.text('Details',),
54
'state': fields.selection([('done','Done'),('skipped','Skipped'),], 'State', size=6, help='The test will be completed only if the module is installed or if the test may be processed on uninstalled module.'),
56
quality_check_detail()
59
class create_quality_check(wizard.interface):
61
def _create_quality_check(self, cr, uid, data, context={}):
62
pool = pooler.get_pool(cr.dbname)
64
for id in data['ids']:
65
module_data = pool.get('ir.module.module').browse(cr, uid, id)
66
#list_folders = os.listdir(config['addons_path']+'/base_module_quality/')
67
abstract_obj = base_module_quality.abstract_quality_check()
71
for test in abstract_obj.tests:
72
ad = tools.config['addons_path']
73
if module_data.name == 'base':
74
ad = tools.config['root_path']+'/addons'
75
module_path = os.path.join(ad, module_data.name)
76
val = test.quality_test()
77
if not val.bool_installed_only or module_data.state == "installed":
78
val.run_test(cr, uid, str(module_path))
82
'score': val.score * 100,
83
'ponderation': val.ponderation,
84
'summary': val.result,
85
'detail': val.result_details,
89
score_sum += val.score * val.ponderation
90
ponderation_sum += val.ponderation
95
'summary': val.result,
105
'summary': _("The module has to be installed before running this test.")
107
create_ids.append((0, 0, data))
109
final_score = '%.2f' % (score_sum / ponderation_sum * 100)
111
'name': module_data.name,
112
'final_score': final_score,
113
'test_ids' : create_ids,
115
obj = pool.get('wizard.quality.check').create(cr, uid, data, context)
119
def _open_quality_check(self, cr, uid, data, context):
120
obj_ids = self._create_quality_check(cr, uid, data, context)
122
'domain': "[('id','in', ["+','.join(map(str,obj_ids))+"])]",
123
'name': _('Quality Check'),
125
'view_mode': 'tree,form',
126
'res_model': 'wizard.quality.check',
127
'type': 'ir.actions.act_window'
133
'result': {'type':'action', 'action':_open_quality_check, 'state':'end'}
137
create_quality_check("create_quality_check_wiz")
139
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
b'\\ No newline at end of file'