From 78d2de2600f3d383edffacb6c0b213b8d8200817 Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Wed, 7 Jan 2009 19:53:15 +0530 Subject: [PATCH 01/10] Corrected terp test on Quality Module bzr revid: jvo@tinyerp.com-20090107142315-xb8qq0u9coexf04m --- .../base_module_quality.py | 2 +- .../method_test/method_test.py | 2 +- .../terp_test/terp_test.py | 26 ++++++++++++++++--- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/addons/base_module_quality/base_module_quality.py b/addons/base_module_quality/base_module_quality.py index 6db637ab32e..1be9de1ec5b 100644 --- a/addons/base_module_quality/base_module_quality.py +++ b/addons/base_module_quality/base_module_quality.py @@ -25,7 +25,7 @@ from tools import config class abstract_quality_check(object): ''' - This Class provide... + This Class provides... ''' def __init__(self): diff --git a/addons/base_module_quality/method_test/method_test.py b/addons/base_module_quality/method_test/method_test.py index 8ca77b996f5..58c536e9e9c 100644 --- a/addons/base_module_quality/method_test/method_test.py +++ b/addons/base_module_quality/method_test/method_test.py @@ -76,7 +76,7 @@ class quality_test(base_module_quality.abstract_quality_check): def get_result(self): summary = """ -This test checks if the module classes are raising exception when calling basic methods or no. +This test checks if the module classes are raising exception when calling basic methods or not. """ return summary diff --git a/addons/base_module_quality/terp_test/terp_test.py b/addons/base_module_quality/terp_test/terp_test.py index f42b697c3ad..70048202cea 100644 --- a/addons/base_module_quality/terp_test/terp_test.py +++ b/addons/base_module_quality/terp_test/terp_test.py @@ -43,6 +43,9 @@ class quality_test(base_module_quality.abstract_quality_check): def run_test(self, cr, uid, module_path): list_files = os.listdir(module_path) + + current_module = module_path.split('/')[-1] + for i in list_files: path = os.path.join(module_path, i) if os.path.isdir(path): @@ -61,24 +64,39 @@ class quality_test(base_module_quality.abstract_quality_check): terp_file = os.path.join(module_path,'__terp__.py') res = eval(tools.file_open(terp_file).read()) - terp_keys = ['category', 'name', 'description', 'author', 'website', 'update_xml', 'init_xml', 'depends', 'version', 'active', 'installable', 'demo_xml'] + terp_keys = ['category', 'name', 'description', 'author', 'website', 'update_xml', 'init_xml', 'depends', 'version', 'active', 'installable', 'demo_xml', 'certificate'] for key in terp_keys: if key in res: - feel_good_factor += 1 + feel_good_factor += 1 # each tag should appear if isinstance(res[key],(str,unicode)): if not res[key]: feel_bad_factor += 1 else: - if key == 'description' and res[key] and len(str(res[key]))>=25: + + if key == 'description' and res[key] and len(str(res[key])) >= 150: # no. of chars should be >=150 feel_good_factor += 1 if res['description'].count('\n') >= 4:# description contains minimum 5 lines feel_good_factor += 1 if key == 'website': - ptrn = re.compile('https?://[\w\.]*') # reg ex matching on temporary basis. + ptrn = re.compile('https?://[\w\.]*') # reg ex matching on temporary basis.Website is correctly formatted result = ptrn.search(str(res[key])) if result: feel_good_factor += 1 + else: + feel_bad_factor += 1 + + if isinstance(res[key],bool): + if key == 'active': + if current_module != 'base': + if res[key]: + feel_bad_factor += 1 + else: + if not res[key]: + feel_bad_factor += 1 + + if key == 'installable' and not res[key]: # installable tag is provided and True + feel_bad_factor +=1 else: feel_bad_factor += 1 From bc3451b40253f5e7812cd78fb3b115bdc4804319 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 7 Jan 2009 17:00:12 +0100 Subject: [PATCH 02/10] [FIX] product: complete_name: pass the context to name_get lp bug: https://launchpad.net/bugs/314723 fixed bzr revid: christophe@tinyerp.com-20090107160012-18v2klefi72tan3k --- addons/product/product.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/product/product.py b/addons/product/product.py index 90348783a0c..8378e682dae 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -174,7 +174,7 @@ product_ul() #---------------------------------------------------------- class product_category(osv.osv): - def name_get(self, cr, uid, ids, context={}): + def name_get(self, cr, uid, ids, context=None): if not len(ids): return [] reads = self.read(cr, uid, ids, ['name','parent_id'], context) @@ -187,7 +187,7 @@ class product_category(osv.osv): return res def _name_get_fnc(self, cr, uid, ids, prop, unknow_none, context): - res = self.name_get(cr, uid, ids) + res = self.name_get(cr, uid, ids, context) return dict(res) _name = "product.category" From 5b6bcfb55917f2755e4998ed5f684a1b19f8d872 Mon Sep 17 00:00:00 2001 From: qdp Date: Thu, 8 Jan 2009 09:49:26 +0100 Subject: [PATCH 03/10] *imrpovements bzr revid: qdp@tinyerp.com-20090108084926-n4dxtv1bczx9id1t --- .../base_module_quality.py | 18 +++---- .../base_module_quality_wizard.xml | 13 +++-- .../method_test/method_test.py | 20 +++----- .../pylint_test/pylint_test.py | 37 +++++++------- .../speed_test/speed_test.py | 51 ++++++++----------- .../terp_test/terp_test.py | 30 +++++------ .../wizard/module_quality_check.py | 26 ++++++---- 7 files changed, 95 insertions(+), 100 deletions(-) diff --git a/addons/base_module_quality/base_module_quality.py b/addons/base_module_quality/base_module_quality.py index 1be9de1ec5b..48a4d6dc69a 100644 --- a/addons/base_module_quality/base_module_quality.py +++ b/addons/base_module_quality/base_module_quality.py @@ -21,6 +21,7 @@ ############################################################################## import pooler import os +import osv from tools import config class abstract_quality_check(object): @@ -77,7 +78,8 @@ class abstract_quality_check(object): ''' 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.. @@ -103,14 +105,12 @@ class abstract_quality_check(object): def format_table(self, header=[], data_list=[]): detail = "" - header_list = [] - final_list = [] - for head in data_list[1]: - header_list.append(head) - detail += (header[0]) % tuple(header_list) - for res in data_list[0]: - data_list[0][res].append(res) - detail += (header[1]) % tuple(data_list[0][res]) + 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 diff --git a/addons/base_module_quality/base_module_quality_wizard.xml b/addons/base_module_quality/base_module_quality_wizard.xml index 5d718385dcc..a33f27342e3 100644 --- a/addons/base_module_quality/base_module_quality_wizard.xml +++ b/addons/base_module_quality/base_module_quality_wizard.xml @@ -21,8 +21,8 @@ form
- - + + @@ -38,8 +38,10 @@ - + + + @@ -55,8 +57,9 @@ tree - - + + + diff --git a/addons/base_module_quality/method_test/method_test.py b/addons/base_module_quality/method_test/method_test.py index 58c536e9e9c..b9c52279875 100644 --- a/addons/base_module_quality/method_test/method_test.py +++ b/addons/base_module_quality/method_test/method_test.py @@ -34,8 +34,6 @@ class quality_test(base_module_quality.abstract_quality_check): self.name = _("Method Test") self.bool_installed_only = True self.ponderation = 1.0 - self.result_det = {} - self.data_list = [] return None def run_test(self, cr, uid, module_path): @@ -44,8 +42,9 @@ class quality_test(base_module_quality.abstract_quality_check): obj_list = self.get_objects(cr, uid, module_name) ok_count = 0 ex_count = 0 + result_dict = {} for obj in obj_list: - temp = [] + temp = [obj] try: res = pool.get(obj).search(cr, uid, []) temp.append('Ok') @@ -67,11 +66,10 @@ class quality_test(base_module_quality.abstract_quality_check): except: temp.append('Exception') ex_count += 1 - self.result_det[obj] = temp - self.data_list.append(self.result_det) + result_dict[obj] = temp self.score = (ok_count + ex_count) and float(ok_count)/float(ok_count + ex_count) or 0.0 self.result = self.get_result() - self.result_details = self.get_result_details() + self.result_details = self.get_result_details(result_dict) return None def get_result(self): @@ -80,15 +78,11 @@ This test checks if the module classes are raising exception when calling basic """ return summary - def get_result_details(self): - header_list = [] - header_list.append('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-16s \n! %-20s \n! %-16s ') - header_list.append('\n|-\n| %s \n| %s \n| %s \n| %s ') - header_view = ['Object Name', 'search()', 'fields_view_get', 'read'] - self.data_list.append(header_view) + def get_result_details(self, dict): + header = ('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-16s \n! %-20s \n! %-16s ', [_('Object Name'), 'search()', 'fields_view_get()', 'read()']) detail = "" if not self.error: - detail += self.format_table(header=header_list, data_list=self.data_list) + detail += self.format_table(header, dict) return detail # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_module_quality/pylint_test/pylint_test.py b/addons/base_module_quality/pylint_test/pylint_test.py index 3c40bad9bb2..7275b378105 100644 --- a/addons/base_module_quality/pylint_test/pylint_test.py +++ b/addons/base_module_quality/pylint_test/pylint_test.py @@ -47,7 +47,8 @@ class quality_test(base_module_quality.abstract_quality_check): n = 0 score = 0.0 - self.result += "\nThis test checks if the module satisfies the current coding standard used by OpenERP. \n\n" + self.result += """\nThis test checks if the module satisfies the current coding standard used by OpenERP. \n +Rating for *.py files goes from -10/10 to 10/10\n\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) @@ -72,29 +73,29 @@ class quality_test(base_module_quality.abstract_quality_check): self.result_details += res average_score = n and score / n or score - self.score = (average_score + 10) /20 + 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===: + #~ 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. +#~ This test checks if the module satisfies the current coding standard used by OpenERP. -""" + "Score: " + str(self.score) + "/10\n" - else: - summary =""" \n===Pylint Test===: +#~ """ + "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 - return summary +#~ The module has to be installed before running this test.\n\n """ + #~ header_list = "" + #~ self.error = True + #~ return summary - def get_result_details(self): - detail = "\n===Pylint Test===\n" + self.result - return detail + #~ def get_result_details(self): + #~ detail = "\n===Pylint Test===\n" + self.result + #~ return detail # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_module_quality/speed_test/speed_test.py b/addons/base_module_quality/speed_test/speed_test.py index d631ab2c96b..1f246ee7f33 100644 --- a/addons/base_module_quality/speed_test/speed_test.py +++ b/addons/base_module_quality/speed_test/speed_test.py @@ -38,9 +38,8 @@ class quality_test(base_module_quality.abstract_quality_check): self.name = _("Speed Test") self.bool_installed_only = True self.ponderation = 1.0 - self.result_det = {} - self.data_list = [] return None + def run_test(self, cr, uid, module_path): pool = pooler.get_pool(cr.dbname) module_name = module_path.split('/')[-1] @@ -48,48 +47,45 @@ class quality_test(base_module_quality.abstract_quality_check): obj_counter = 0 score = 0 obj_ids = self.get_ids(cr, uid, obj_list) + result_dict = {} for obj in obj_ids: obj_counter += 1 ids = obj_ids[obj] ids = ids[:100] size = len(ids) if size: - c1 = cr.count + list = [] + #we perform the operation twice, and count the number of queries in the second run. This allows to avoid the cache effect. (like translated terms that asks for more queries) pool.get(obj).read(cr, uid, [ids[0]]) + c = cr.count pool.get(obj).read(cr, uid, [ids[0]]) - code_base_complexity = cr.count - c1 + code_base_complexity = cr.count - c pool.get(obj).read(cr, uid, ids[:size/2]) + c = cr.count pool.get(obj).read(cr, uid, ids[:size/2]) - code_half_complexity = cr.count - c1 + code_half_complexity = cr.count - c pool.get(obj).read(cr, uid, ids) + c = cr.count pool.get(obj).read(cr, uid, ids) - code_size_complexity = cr.count - c1 + code_size_complexity = cr.count - c if size < 5: - self.score += -2 - list = [size, code_base_complexity, code_half_complexity, code_size_complexity, "Warning! Not enough demo data"] - self.result_det[obj] = list + list = [obj, size, code_base_complexity, code_half_complexity, code_size_complexity, "Warning! Not enough demo data"] else: if code_size_complexity <= (code_base_complexity + size): complexity = "O(1)" - score = 10 + score += 1 else: complexity = "O(n) or worst" - score = 0 - list = [size, code_base_complexity, code_half_complexity, code_size_complexity, complexity] - self.result_det[obj] = list + list = [obj, size, code_base_complexity, code_half_complexity, code_size_complexity, complexity] else: - score += -5 - list = [size, "", "", "", "Warning! Object has no demo data"] - self.result_det[obj] = list - self.data_list.append(self.result_det) - self.score = obj_counter and score/obj_counter or 0.0 - self.result = self.get_result() - self.result_details = self.get_result_details() - + list = [obj, size, "", "", "", "Warning! Object has no demo data"] + result_dict[obj] = list + self.score = obj_counter and score / obj_counter or 0.0 + self.result_details = self.get_result_details(result_dict) return None def get_result(self): @@ -98,16 +94,11 @@ This test checks the speed of the module. """ return summary - def get_result_details(self): - header_list = [] - header_list.append('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-10s \n! %-10s \n! %-10s \n! %-10s \n! %-20s') - header_list.append('\n|-\n| %s \n| %s \n| %s \n| %s \n| %s \n| %s ') - header_view = ['Object Name', 'Size-Number of Records (S)', '1', 'S/2', 'S', 'Complexity using query'] - detail = "" - self.data_list.append(header_view) + def get_result_details(self, dict): + header = ('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-10s \n! %-10s \n! %-10s \n! %-10s \n! %-20s', [_('Object Name'), _('Size-Number of Records (S)'), _('1'), _('S/2'), _('S'), _('Reading Complexity')]) if not self.error: - detail += self.format_table(header=header_list, data_list=self.data_list) - return detail + return self.format_table(header, data_list=dict) + return "" # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_module_quality/terp_test/terp_test.py b/addons/base_module_quality/terp_test/terp_test.py index 70048202cea..c55b5222df2 100644 --- a/addons/base_module_quality/terp_test/terp_test.py +++ b/addons/base_module_quality/terp_test/terp_test.py @@ -58,8 +58,8 @@ class quality_test(base_module_quality.abstract_quality_check): feel_bad_factor = 0 if '__terp__.py' not in list_files: self.no_terp = True - if self.no_terp: self.result += "The module does not contain the __terp__.py file" + return None terp_file = os.path.join(module_path,'__terp__.py') res = eval(tools.file_open(terp_file).read()) @@ -105,21 +105,21 @@ class quality_test(base_module_quality.abstract_quality_check): # 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 + #~ 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 - def get_result_details(self): - detail = "\n===TERP Test===\n" + self.result - return detail + #~ def get_result_details(self): + #~ detail = "\n===TERP Test===\n" + self.result + #~ return detail diff --git a/addons/base_module_quality/wizard/module_quality_check.py b/addons/base_module_quality/wizard/module_quality_check.py index 827e4719800..1cd2031f202 100644 --- a/addons/base_module_quality/wizard/module_quality_check.py +++ b/addons/base_module_quality/wizard/module_quality_check.py @@ -35,8 +35,8 @@ class wiz_quality_check(osv.osv): _name = 'wizard.quality.check' _columns = { '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',) + 'final_score': fields.char('Final Score (%)', size=10,), + 'test_ids' : fields.one2many('quality.check.detail', 'quality_check_id', 'Tests',) } wiz_quality_check() @@ -46,10 +46,11 @@ class quality_check_detail(osv.osv): _columns = { 'quality_check_id': fields.many2one('wizard.quality.check', 'Quality'), 'name': fields.char('Name',size=128,), - 'score': fields.float('Score',), - 'ponderation': fields.float('Ponderation',), + 'score': fields.float('Score (%)',), + 'ponderation': fields.float('Ponderation',help='Some tests are more critical than others, so they have a bigger weight in the computation of final rating'), 'summary': fields.text('Summary',), 'detail' : fields.text('Details',), + '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.'), } quality_check_detail() @@ -58,8 +59,10 @@ 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] + print data, context + objs = [] + for id in data['ids']: + module_data = pool.get('ir.module.module').browse(cr, uid, id) #list_folders = os.listdir(config['addons_path']+'/base_module_quality/') abstract_obj = base_module_quality.abstract_quality_check() score_sum = 0.0 @@ -76,10 +79,11 @@ class create_quality_check(wizard.interface): val.run_test(cr, uid, str(module_path)) data = { 'name': val.name, - 'score': val.score, + 'score': val.score * 100, 'ponderation': val.ponderation, 'summary': val.result, 'detail': val.result_details, + 'state': 'done', } create_ids.append((0,0,data)) score_sum += val.score * val.ponderation @@ -88,6 +92,7 @@ class create_quality_check(wizard.interface): data = { 'name': val.name, 'score': 0, + 'state': 'skipped', 'summary': _("The module has to be installed before running this test.") } create_ids.append((0,0,data)) @@ -99,12 +104,13 @@ class create_quality_check(wizard.interface): 'test_ids' : create_ids, } obj = pool.get('wizard.quality.check').create(cr, uid, data, context) - return obj + objs.append(obj) + return objs def _open_quality_check(self, cr, uid, data, context): - obj_id = self._create_quality_check(cr, uid, data, context) + obj_ids = self._create_quality_check(cr, uid, data, context) return { - 'domain': "[('id','=', "+ str(obj_id)+")]", + 'domain': "[('id','in', ["+','.join(map(str,obj_ids))+"])]", 'name': _('Quality Check'), 'view_type': 'form', 'view_mode': 'tree,form', From 69e276222efb679980aa01a53fef92f7ea18a045 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 8 Jan 2009 10:37:58 +0100 Subject: [PATCH 04/10] [FIX] fix a bug in the "Close fiscal year wizard" that avoiding to close a fiscal year without creating new entries bzr revid: christophe@tinyerp.com-20090108093758-tf3urqgh8oejhzqk --- addons/account/wizard/wizard_fiscalyear_close.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/account/wizard/wizard_fiscalyear_close.py b/addons/account/wizard/wizard_fiscalyear_close.py index 7dfc86ac5c3..fcb51906f3d 100644 --- a/addons/account/wizard/wizard_fiscalyear_close.py +++ b/addons/account/wizard/wizard_fiscalyear_close.py @@ -55,14 +55,15 @@ def _data_save(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) fy_id = data['form']['fy_id'] + new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id']) + start_jp = new_fyear.start_journal_period_id + if data['form']['report_new']: periods_fy2 = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id']).period_ids if not periods_fy2: raise wizard.except_wizard(_('UserError'), _('There are no periods defined on New Fiscal Year.')) period=periods_fy2[0] - new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id']) - start_jp = new_fyear.start_journal_period_id if not start_jp: raise wizard.except_wizard(_('UserError'), _('The new fiscal year should have a journal for new entries define on it')) @@ -163,7 +164,7 @@ def _data_save(self, cr, uid, data, context): 'WHERE fiscalyear_id = %s', ('done',fy_id)) cr.execute('UPDATE account_fiscalyear ' \ 'SET state = %s, end_journal_period_id = %s' \ - 'WHERE id = %s', ('done',start_jp.id,fy_id)) + 'WHERE id = %s', ('done', start_jp and start_jp.id or None, fy_id)) return {} class wiz_journal_close(wizard.interface): From e96989b95e7e7668cf0e4781899728ac8216ce3c Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 8 Jan 2009 11:08:56 +0100 Subject: [PATCH 05/10] [FIX] closing fiscal year wizard: bugfix in sql query bzr revid: christophe@tinyerp.com-20090108100856-y2r0b6pftoilvq10 --- addons/account/wizard/wizard_fiscalyear_close.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/wizard/wizard_fiscalyear_close.py b/addons/account/wizard/wizard_fiscalyear_close.py index fcb51906f3d..2aa218088d8 100644 --- a/addons/account/wizard/wizard_fiscalyear_close.py +++ b/addons/account/wizard/wizard_fiscalyear_close.py @@ -163,7 +163,7 @@ def _data_save(self, cr, uid, data, context): cr.execute('UPDATE account_period SET state = %s ' \ 'WHERE fiscalyear_id = %s', ('done',fy_id)) cr.execute('UPDATE account_fiscalyear ' \ - 'SET state = %s, end_journal_period_id = %s' \ + 'SET state = %s, end_journal_period_id = %s ' \ 'WHERE id = %s', ('done', start_jp and start_jp.id or None, fy_id)) return {} From d6219e509d6f94e700c73c3c5b9c3724e6659632 Mon Sep 17 00:00:00 2001 From: "Apa (Open ERP)" Date: Thu, 8 Jan 2009 16:24:31 +0530 Subject: [PATCH 06/10] for invoice, ca, u plz, put disc(%) the label of the column on the same line, like for sale order=Done bzr revid: apa@tinyerp.com-20090108105431-uet3mmjsu0rgpqff --- addons/account/report/invoice.rml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/report/invoice.rml b/addons/account/report/invoice.rml index e1a65319898..40d768e0935 100644 --- a/addons/account/report/invoice.rml +++ b/addons/account/report/invoice.rml @@ -297,7 +297,7 @@ - + Description @@ -312,7 +312,7 @@ Unit Price - Disc. (%) + Disc.(%) Price From bd79edc10e43011d2d16d4ae22bcf05f1688a2e8 Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Thu, 8 Jan 2009 12:33:59 +0100 Subject: [PATCH 07/10] [FIX] Typo bzr revid: stephane@tinyerp.com-20090108113359-rkerxjd5iz6qe52n --- addons/account/account.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index bbd88d10b2c..af54ce70206 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1224,15 +1224,15 @@ class account_tax(osv.osv): # 'base_code_id': fields.many2one('account.tax.code', 'Base Code', help="Use this code for the VAT declaration."), 'tax_code_id': fields.many2one('account.tax.code', 'Tax Code', help="Use this code for the VAT declaration."), - 'base_sign': fields.float('Base Code Sign', help="Usualy 1 or -1."), - 'tax_sign': fields.float('Tax Code Sign', help="Usualy 1 or -1."), + 'base_sign': fields.float('Base Code Sign', help="Usually 1 or -1."), + 'tax_sign': fields.float('Tax Code Sign', help="Usually 1 or -1."), # Same fields for refund invoices 'ref_base_code_id': fields.many2one('account.tax.code', 'Refund Base Code', help="Use this code for the VAT declaration."), 'ref_tax_code_id': fields.many2one('account.tax.code', 'Refund Tax Code', help="Use this code for the VAT declaration."), - 'ref_base_sign': fields.float('Base Code Sign', help="Usualy 1 or -1."), - 'ref_tax_sign': fields.float('Tax Code Sign', help="Usualy 1 or -1."), + 'ref_base_sign': fields.float('Base Code Sign', help="Usually 1 or -1."), + 'ref_tax_sign': fields.float('Tax Code Sign', help="Usually 1 or -1."), 'include_base_amount': fields.boolean('Include in base amount', help="Indicate if the amount of tax must be included in the base amount for the computation of the next taxes"), 'company_id': fields.many2one('res.company', 'Company', required=True), 'description': fields.char('Internal Name',size=32), From b141de765db622f36e195261426756a343dd96c7 Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Thu, 8 Jan 2009 18:05:15 +0530 Subject: [PATCH 08/10] Corrections on reports(Ref: VRA) bzr revid: jvo@tinyerp.com-20090108123515-helru2m311uskjsk --- addons/account/report/invoice.rml | 8 ++++---- addons/account/wizard/wizard_fiscalyear_close.py | 4 ++-- .../report/report_account_invoice_layout.rml | 4 ++-- .../report/special_message_invoice.rml | 4 ++-- addons/mrp_repair/report/order.rml | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/addons/account/report/invoice.rml b/addons/account/report/invoice.rml index 40d768e0935..74c873f9374 100644 --- a/addons/account/report/invoice.rml +++ b/addons/account/report/invoice.rml @@ -350,7 +350,7 @@ - [[ format(l.note or removeParentNode('tr')) ]] + [[ format(l.note) or removeParentNode('tr') ]] @@ -463,7 +463,7 @@ - + @@ -541,7 +541,7 @@ - [[ format(o.comment or removeParentNode('blockTable')) ]] + [[ format(o.comment) or removeParentNode('blockTable') ]] @@ -551,7 +551,7 @@ - [[ format((o.payment_term and o.payment_term.note) or removeParentNode('blockTable')) ]] + [[ format(o.payment_term and o.payment_term.note) or removeParentNode('blockTable') ]] diff --git a/addons/account/wizard/wizard_fiscalyear_close.py b/addons/account/wizard/wizard_fiscalyear_close.py index 2aa218088d8..7f1928d816c 100644 --- a/addons/account/wizard/wizard_fiscalyear_close.py +++ b/addons/account/wizard/wizard_fiscalyear_close.py @@ -51,7 +51,7 @@ def _data_load(self, cr, uid, data, context): def _data_save(self, cr, uid, data, context): if not data['form']['sure']: - raise wizard.except_wizard(_('UserError'), _('Closing of fiscal year canceled, please check the box !')) + raise wizard.except_wizard(_('UserError'), _('Closing of fiscal year cancelled, please check the box !')) pool = pooler.get_pool(cr.dbname) fy_id = data['form']['fy_id'] @@ -99,7 +99,7 @@ def _data_save(self, cr, uid, data, context): 'period_id': period.id, 'account_id': account.id }, {'journal_id': new_journal.id, 'period_id':period.id}) - if accnt_type_data.close_method=='unreconciled': + if accnt_type_data.close_method == 'unreconciled': offset = 0 limit = 100 while True: diff --git a/addons/account_invoice_layout/report/report_account_invoice_layout.rml b/addons/account_invoice_layout/report/report_account_invoice_layout.rml index 9690d42236a..e118288b547 100644 --- a/addons/account_invoice_layout/report/report_account_invoice_layout.rml +++ b/addons/account_invoice_layout/report/report_account_invoice_layout.rml @@ -287,11 +287,11 @@ -[[ format(o.comment or '') ]] +[[ format(o.comment) or '' ]] -[[ format((o.payment_term and o.payment_term.note) or '') ]] +[[ format(o.payment_term and o.payment_term.note) or '' ]] diff --git a/addons/account_invoice_layout/report/special_message_invoice.rml b/addons/account_invoice_layout/report/special_message_invoice.rml index 1e146007883..e29f845e185 100644 --- a/addons/account_invoice_layout/report/special_message_invoice.rml +++ b/addons/account_invoice_layout/report/special_message_invoice.rml @@ -287,11 +287,11 @@ -[[ format(o.comment or '') ]] +[[ format(o.comment) or '' ]] -[[ format((o.payment_term and o.payment_term.note) or '') ]] +[[ format(o.payment_term and o.payment_term.note) or '' ]]
[[ repeatIn((spcl_msg(data['form']) and spcl_msg(data['form']).splitlines()) or [], 'note') ]] [[ note or removeParentNode('para') ]] diff --git a/addons/mrp_repair/report/order.rml b/addons/mrp_repair/report/order.rml index 4151811f0ea..781bffaae59 100644 --- a/addons/mrp_repair/report/order.rml +++ b/addons/mrp_repair/report/order.rml @@ -395,7 +395,7 @@ - [[ format(o.quotation_notes or '') ]] + [[ format(o.quotation_notes) or '' ]] From 8a06bea953c16c90d4bef269638b5d6b467b89a9 Mon Sep 17 00:00:00 2001 From: qdp Date: Thu, 8 Jan 2009 14:03:20 +0100 Subject: [PATCH 09/10] base_module_quality improvements: *added note field *improved transability *improved output *cleaned *modified format_table method bzr revid: qdp@tinyerp.com-20090108130320-ypcc4jxbx51jv1ra --- .../base_module_quality.py | 3 ++ .../base_module_quality_wizard.xml | 1 + .../method_test/method_test.py | 25 +++++------ .../pylint_test/pylint_test.py | 41 +++++++------------ .../speed_test/speed_test.py | 39 ++++++++++++------ .../terp_test/terp_test.py | 22 ++++++++-- .../wizard/module_quality_check.py | 3 ++ 7 files changed, 78 insertions(+), 56 deletions(-) diff --git a/addons/base_module_quality/base_module_quality.py b/addons/base_module_quality/base_module_quality.py index 48a4d6dc69a..4590a51dfe3 100644 --- a/addons/base_module_quality/base_module_quality.py +++ b/addons/base_module_quality/base_module_quality.py @@ -41,6 +41,9 @@ class abstract_quality_check(object): #This char have to store the name of the test. self.name = "" + #This char have to store the aim of the test and eventually a note. + self.note = "" + #This char have to store the result. #Used to display the result of the test. self.result = "" diff --git a/addons/base_module_quality/base_module_quality_wizard.xml b/addons/base_module_quality/base_module_quality_wizard.xml index a33f27342e3..d60ab6d3b29 100644 --- a/addons/base_module_quality/base_module_quality_wizard.xml +++ b/addons/base_module_quality/base_module_quality_wizard.xml @@ -38,6 +38,7 @@ + diff --git a/addons/base_module_quality/method_test/method_test.py b/addons/base_module_quality/method_test/method_test.py index b9c52279875..1abaa288e86 100644 --- a/addons/base_module_quality/method_test/method_test.py +++ b/addons/base_module_quality/method_test/method_test.py @@ -32,6 +32,9 @@ class quality_test(base_module_quality.abstract_quality_check): def __init__(self): super(quality_test, self).__init__() self.name = _("Method Test") + self.note = _(""" +This test checks if the module classes are raising exception when calling basic methods or not. +""") self.bool_installed_only = True self.ponderation = 1.0 return None @@ -47,38 +50,32 @@ class quality_test(base_module_quality.abstract_quality_check): temp = [obj] try: res = pool.get(obj).search(cr, uid, []) - temp.append('Ok') + temp.append(_('Ok')) ok_count += 1 except: - temp.append('Exception') + temp.append(_('Exception')) ex_count += 1 try: res1 = pool.get(obj).fields_view_get(cr, uid,) - temp.append('Ok') + temp.append(_('Ok')) ok_count += 1 except: - temp.append('Exception') + temp.append(_('Exception')) ex_count += 1 try: res2 = pool.get(obj).read(cr, uid, []) - temp.append('Ok') + temp.append(_('Ok')) ok_count += 1 except: - temp.append('Exception') + temp.append(_('Exception')) ex_count += 1 result_dict[obj] = temp self.score = (ok_count + ex_count) and float(ok_count)/float(ok_count + ex_count) or 0.0 - self.result = self.get_result() - self.result_details = self.get_result_details(result_dict) + self.result = self.get_result(result_dict) return None - def get_result(self): - summary = """ -This test checks if the module classes are raising exception when calling basic methods or not. -""" - return summary - def get_result_details(self, dict): + def get_result(self, dict): header = ('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-16s \n! %-20s \n! %-16s ', [_('Object Name'), 'search()', 'fields_view_get()', 'read()']) detail = "" if not self.error: diff --git a/addons/base_module_quality/pylint_test/pylint_test.py b/addons/base_module_quality/pylint_test/pylint_test.py index 7275b378105..930ab7d29f1 100644 --- a/addons/base_module_quality/pylint_test/pylint_test.py +++ b/addons/base_module_quality/pylint_test/pylint_test.py @@ -32,6 +32,7 @@ class quality_test(base_module_quality.abstract_quality_check): def __init__(self): super(quality_test, self).__init__() self.name = _("Pylint Test") + self.note = _("""This test uses Pylint and checks if the module satisfies the coding standard of Python. See http://www.logilab.org/project/name/pylint for further info.\n """) self.bool_installed_only = False self.ponderation = 1.0 return None @@ -47,8 +48,8 @@ class quality_test(base_module_quality.abstract_quality_check): n = 0 score = 0.0 - self.result += """\nThis test checks if the module satisfies the current coding standard used by OpenERP. \n -Rating for *.py files goes from -10/10 to 10/10\n\n""" + dict = {} + self.result_details += '' 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) @@ -66,36 +67,24 @@ Rating for *.py files goes from -10/10 to 10/10\n\n""" rightchar += 1 try: score += float(res[leftchar+1:rightchar]) - self.result += file + ": " + res[leftchar+1:rightchar] + "/10\n" + #self.result += file + ": " + res[leftchar+1:rightchar] + "/10\n" + dict[file] = [file, res[leftchar+1:rightchar]] except: score += 0 - self.result += file + ": "+_("Unable to parse the result. Check the details.")+"\n" + #self.result += file + ": "+_("Unable to parse the result. Check the details.")+"\n" + dict[file] = [file, _("Unable to parse the result. Check the details.")] self.result_details += res - + self.result_details += '' average_score = n and score / n or score - self.score = (average_score + 10) / 20 + self.score = (max(average_score,0)) / 10 + self.result = self.get_result(dict) 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" - #~ else: - #~ summary =""" \n===Pylint Test===: - -#~ The module has to be installed before running this test.\n\n """ - #~ header_list = "" - #~ self.error = True - #~ return summary - - #~ def get_result_details(self): - #~ detail = "\n===Pylint Test===\n" + self.result - #~ return detail + def get_result(self, dict): + header = ('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-10s \n', [_('File Name'), _('Result (/10)'),]) + if not self.error: + return self.format_table(header, data_list=dict) + return "" # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_module_quality/speed_test/speed_test.py b/addons/base_module_quality/speed_test/speed_test.py index 1f246ee7f33..d35f6362074 100644 --- a/addons/base_module_quality/speed_test/speed_test.py +++ b/addons/base_module_quality/speed_test/speed_test.py @@ -35,9 +35,13 @@ class quality_test(base_module_quality.abstract_quality_check): def __init__(self): super(quality_test, self).__init__() - self.name = _("Speed Test") self.bool_installed_only = True self.ponderation = 1.0 + self.name = _("Speed Test") + self.note = _(""" +This test checks the speed of the module. Note that at least 5 demo data is needed in order to run it. + +""") return None def run_test(self, cr, uid, module_path): @@ -48,6 +52,8 @@ class quality_test(base_module_quality.abstract_quality_check): score = 0 obj_ids = self.get_ids(cr, uid, obj_list) result_dict = {} + result_dict2 = {} + self.result_details += _("O(1) means that the number of SQL requests to read the object does not depand on the number of objects we are reading. This feature is hardly wished.\n") for obj in obj_ids: obj_counter += 1 ids = obj_ids[obj] @@ -73,29 +79,38 @@ class quality_test(base_module_quality.abstract_quality_check): code_size_complexity = cr.count - c if size < 5: - list = [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")] else: if code_size_complexity <= (code_base_complexity + size): - complexity = "O(1)" + complexity = _("O(1)") score += 1 + list2 = [obj, _("Efficient")] else: - complexity = "O(n) or worst" + complexity = _("O(n) or worst") + list2 = [obj, _("Not Efficient")] + list = [obj, size, code_base_complexity, code_half_complexity, code_size_complexity, complexity] + else: - list = [obj, size, "", "", "", "Warning! Object has no demo data"] + list = [obj, size, "", "", "", _("Warning! Object has no demo data")] + list2 = [obj, _("No demo data")] result_dict[obj] = list + result_dict2[obj] = list2 + self.score = obj_counter and score / obj_counter or 0.0 - self.result_details = self.get_result_details(result_dict) + self.result_details += self.get_result_details(result_dict) + self.result += self.get_result(result_dict2) + return None - def get_result(self): - summary = """ -This test checks the speed of the module. -""" - return summary + def get_result(self, dict): + header = ('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-10s \n', [_('Object Name'), _('Result'),]) + if not self.error: + return self.format_table(header, data_list=dict) + return "" def get_result_details(self, dict): - header = ('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-10s \n! %-10s \n! %-10s \n! %-10s \n! %-20s', [_('Object Name'), _('Size-Number of Records (S)'), _('1'), _('S/2'), _('S'), _('Reading Complexity')]) + header = ('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-10s \n! %-10s \n! %-10s \n! %-10s \n! %-20s', [_('Object Name'), _('N (Number of Records)'), _('1'), _('N/2'), _('N'), _('Reading Complexity')]) if not self.error: return self.format_table(header, data_list=dict) return "" diff --git a/addons/base_module_quality/terp_test/terp_test.py b/addons/base_module_quality/terp_test/terp_test.py index c55b5222df2..cf9977c89b7 100644 --- a/addons/base_module_quality/terp_test/terp_test.py +++ b/addons/base_module_quality/terp_test/terp_test.py @@ -35,13 +35,14 @@ class quality_test(base_module_quality.abstract_quality_check): # ''' super(quality_test, self).__init__() self.name = _("Terp Test") + self.note = _("This test checks if the module satisfies the current coding standard used by OpenERP.") self.bool_installed_only = False self.no_terp = False self.ponderation = 2 return None - def run_test(self, cr, uid, module_path): + def run_test_terp(self, cr, uid, module_path): list_files = os.listdir(module_path) current_module = module_path.split('/')[-1] @@ -58,7 +59,7 @@ class quality_test(base_module_quality.abstract_quality_check): feel_bad_factor = 0 if '__terp__.py' not in list_files: self.no_terp = True - self.result += "The module does not contain the __terp__.py file" + self.result += _("The module does not contain the __terp__.py file") return None terp_file = os.path.join(module_path,'__terp__.py') @@ -100,11 +101,24 @@ class quality_test(base_module_quality.abstract_quality_check): else: feel_bad_factor += 1 - self.score = round((feel_good_factor) / float(feel_good_factor + feel_bad_factor),2) - self.result += "\nThis test checks if the module satisfies the current coding standard for __terp__.py file used by OpenERP." + score = round((feel_good_factor) / float(feel_good_factor + feel_bad_factor),2) + # self.result += "__terp__.py : "+ str(self.score) + "/10\n" + return [_('__terp__.py file'), score] + + + def run_test(self, cr, uid, module_path): + terp_score = self.run_test_terp(cr, uid, module_path) + self.score = terp_score[1] + self.result = self.get_result({'__terp__.py': terp_score}) return None + def get_result(self, dict): + header = ('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-10s \n', [_('Object Name'), _('Result (/1)'),]) + if not self.error: + return self.format_table(header, data_list=dict) + return "" + #~ def get_result(self, cr, uid, module_path, module_state): #~ # self.run_test(cr, uid, module_path) #~ # summary = "\n===TERP Test===:\n" diff --git a/addons/base_module_quality/wizard/module_quality_check.py b/addons/base_module_quality/wizard/module_quality_check.py index 1cd2031f202..002810b7976 100644 --- a/addons/base_module_quality/wizard/module_quality_check.py +++ b/addons/base_module_quality/wizard/module_quality_check.py @@ -48,6 +48,7 @@ class quality_check_detail(osv.osv): 'name': fields.char('Name',size=128,), 'score': fields.float('Score (%)',), 'ponderation': fields.float('Ponderation',help='Some tests are more critical than others, so they have a bigger weight in the computation of final rating'), + 'note': fields.text('Note',), 'summary': fields.text('Summary',), 'detail' : fields.text('Details',), '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.'), @@ -84,6 +85,7 @@ class create_quality_check(wizard.interface): 'summary': val.result, 'detail': val.result_details, 'state': 'done', + 'note': val.note, } create_ids.append((0,0,data)) score_sum += val.score * val.ponderation @@ -91,6 +93,7 @@ class create_quality_check(wizard.interface): else: data = { 'name': val.name, + 'note': val.note, 'score': 0, 'state': 'skipped', 'summary': _("The module has to be installed before running this test.") From 3822eeb075b98701c34c42ec448594fde251b505 Mon Sep 17 00:00:00 2001 From: qdp Date: Thu, 8 Jan 2009 14:21:34 +0100 Subject: [PATCH 10/10] [FIX]fixed recursion problem when closing fiscalyear lp bug: https://launchpad.net/bugs/314979 fixed bzr revid: qdp@tinyerp.com-20090108132134-83fb7xtd2qtm89dq --- addons/account/account_move_line.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index ee98934d91e..a6d44eda261 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -791,6 +791,7 @@ class account_move_line(osv.osv): move_id = vals.get('move_id', False) journal = self.pool.get('account.journal').browse(cr, uid, context['journal_id']) + is_new_move = False if not move_id: if journal.centralisation: # use the first move ever created for this journal and period @@ -815,10 +816,7 @@ class account_move_line(osv.osv): vals['move_id'] = move_id else: raise osv.except_osv(_('No piece number !'), _('Can not create an automatic sequence for this piece !\n\nPut a sequence in the journal definition for automatic numbering or create a sequence manually for this piece.')) - else: - if 'date' in vals: - self.pool.get('account.move').write(cr, uid, [move_id], {'date':vals['date']}, context=context) - del vals['date'] + is_new_move = True ok = not (journal.type_control_ids or journal.account_control_ids) if ('account_id' in vals): @@ -931,6 +929,8 @@ class account_move_line(osv.osv): if data['tax_code_id']: self.create(cr, uid, data, context) + if not is_new_move and 'date' in vals: + self.pool.get('account.move').write(cr, uid, [move_id], {'date':vals['date']}, context=context) if check: tmp = self.pool.get('account.move').validate(cr, uid, [vals['move_id']], context) if journal.entry_posted and tmp: