From 75c4e2b3ed6e1da96657c65e778ea244e7ad8595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 9 Jan 2008 23:41:42 +0100 Subject: [PATCH] Instanciate report object on demand and remove tricky update dict on inherited report --- trytond/ir/actions.py | 2 -- trytond/pooler.py | 2 -- trytond/report/report.py | 19 ++++--------------- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/trytond/ir/actions.py b/trytond/ir/actions.py index dc546a3a3a..2a95d8e0e4 100644 --- a/trytond/ir/actions.py +++ b/trytond/ir/actions.py @@ -107,11 +107,9 @@ class ActionsReport(OSV): 'report_content': fields.function(_report_content, fnct_inv=_report_content_inv, method=True, type='binary', string='Content',), - 'auto': fields.boolean('Automatic', required=True), } _defaults = { 'type': lambda *a: 'ir.actions.report', - 'auto': lambda *a: True, 'report_content': lambda *a: False, } diff --git a/trytond/pooler.py b/trytond/pooler.py index 37728958a2..100e1c9fc8 100644 --- a/trytond/pooler.py +++ b/trytond/pooler.py @@ -39,8 +39,6 @@ def get_db_and_pool(db_name, force_demo=False, update_module=False, load_modules(database, force_demo, update_module) if not update_module: - #import report - #report.interface.register_all(database) pool.get('ir.cron').pool_jobs(database.dbname) if wizard: return database, pool_wizard diff --git a/trytond/report/report.py b/trytond/report/report.py index 3ce7825a29..afeccb46c6 100644 --- a/trytond/report/report.py +++ b/trytond/report/report.py @@ -30,8 +30,8 @@ class ReportService(Service): try: report = pooler.get_pool_report(cursor.dbname).get(report_name) if not report: - self.abort_response('Report Error', 'warning', - 'Report %s doesn\'t exist' % str(report_name)) + report = Report.create_instance(self, 'report', pooler.get_pool(cursor.dbname)) + report._name = report_name res = report.execute(cursor, user, ids, datas, context) return res except ExceptORM, inst: @@ -113,20 +113,8 @@ class Report(object): put objs in the pool var """ if pool.get(cls._name): - parent_class = pool.get(cls._name).__class__ - nattr = {} - for i in ( - '_context', - ): - new = copy.copy(getattr(pool.get(cls._name), i)) - if hasattr(new, 'update'): - new.update(cls.__dict__.get(i, {})) - else: - new.extend(cls.__dict__.get(i, [])) - nattr[i] = new cls = type(cls._name, (cls, parent_class), nattr) - obj = object.__new__(cls) obj.__init__(pool, pool_obj) return obj @@ -134,7 +122,8 @@ class Report(object): create_instance = classmethod(create_instance) def __init__(self, pool, pool_obj): - pool.add(self._name, self) + if self._name: + pool.add(self._name, self) self.pool = pool_obj super(Report, self).__init__()