From 6f524993c38e6021dfbf246ee075f1571c8a6a00 Mon Sep 17 00:00:00 2001 From: ced <> Date: Thu, 7 Jun 2007 12:00:30 +0000 Subject: [PATCH] KERNEL: add test for duplicate report and wizard Remove/Fix all the duplicate report and wizard Don't instanciate auto report when update as there are already Instanciate auto report only if it don't exist in netsvc bzr revid: ced-f59b375f6fc502b8a3e6009162502e2becfc82f7 --- bin/netsvc.py | 3 +++ bin/pooler.py | 5 +++-- bin/report/interface.py | 3 +++ bin/wizard/__init__.py | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/netsvc.py b/bin/netsvc.py index d6e852d76cc..00d833a3061 100644 --- a/bin/netsvc.py +++ b/bin/netsvc.py @@ -108,6 +108,9 @@ class LocalService(Service): class ServiceUnavailable(Exception): pass +def service_exist(name): + return (name in _service) + LOG_DEBUG='debug' LOG_INFO='info' LOG_WARNING='warn' diff --git a/bin/pooler.py b/bin/pooler.py index 87ab9b740d0..95eb13314a2 100644 --- a/bin/pooler.py +++ b/bin/pooler.py @@ -50,8 +50,9 @@ def get_db_and_pool(db_name, force_demo=False, status={}, update_module=False): pool_dic[db_name] = pool addons.load_modules(db, force_demo, status, update_module) - import report - report.interface.register_all(db) + if not update_module: + import report + report.interface.register_all(db) pool.get('ir.cron')._poolJobs(db.dbname) return db, pool diff --git a/bin/report/interface.py b/bin/report/interface.py index 88036afcdc4..4091c717650 100644 --- a/bin/report/interface.py +++ b/bin/report/interface.py @@ -54,6 +54,7 @@ def toxml(val): class report_int(netsvc.Service): def __init__(self, name, audience='*'): + assert not netsvc.service_exist(name), 'The report "%s" already exist!'%name super(report_int, self).__init__(name, audience) if name[0:7]<>'report.': raise 'ConceptionError, bad report name, should start with "report."' @@ -188,6 +189,8 @@ def register_all(db): result = cr.dictfetchall() cr.close() for r in result: + if netsvc.service_exist('report.'+r['report_name']): + continue if r['report_rml']: report_sxw('report.'+r['report_name'], r['model'], opj('addons',r['report_rml']), header=r['header']) if r['report_xsl']: diff --git a/bin/wizard/__init__.py b/bin/wizard/__init__.py index 569ecddcd02..08ff36574b4 100644 --- a/bin/wizard/__init__.py +++ b/bin/wizard/__init__.py @@ -43,6 +43,7 @@ class interface(netsvc.Service): states = {} def __init__(self, name): + assert not netsvc.service_exist('wizard.'+name), 'The wizard "%s" already exist!'%name super(interface, self).__init__('wizard.'+name) self.exportMethod(self.execute) self.wiz_name = name