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
This commit is contained in:
ced 2007-06-07 12:00:30 +00:00
parent c10621cc83
commit 6f524993c3
4 changed files with 10 additions and 2 deletions

View File

@ -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'

View File

@ -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

View File

@ -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']:

View File

@ -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