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 1/3] 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__() From 4c27c179dc362cc346db4b42c523613966e7d75b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 9 Jan 2008 23:50:42 +0100 Subject: [PATCH 2/3] Add missing parent_class variable --- trytond/report/report.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/trytond/report/report.py b/trytond/report/report.py index afeccb46c6..7e88a579c5 100644 --- a/trytond/report/report.py +++ b/trytond/report/report.py @@ -113,7 +113,8 @@ class Report(object): put objs in the pool var """ if pool.get(cls._name): - cls = type(cls._name, (cls, parent_class), nattr) + parent_class = pool.get(cls._name).__class__ + cls = type(cls._name, (cls, parent_class), {}) obj = object.__new__(cls) obj.__init__(pool, pool_obj) From a49da4d222f133a0547048ae938d698d2e64799e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 9 Jan 2008 23:51:25 +0100 Subject: [PATCH 3/3] Make inheritance be done in the __init__ function --- trytond/osv/osv.py | 16 +--------------- trytond/wizard/wizard.py | 13 +------------ 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/trytond/osv/osv.py b/trytond/osv/osv.py index 39fba2eb83..a231aad97f 100644 --- a/trytond/osv/osv.py +++ b/trytond/osv/osv.py @@ -172,21 +172,7 @@ class OSV(ORM): """ if pool.get(cls._name): parent_class = pool.get(cls._name).__class__ - nattr = {} - for i in ( - '_columns', - '_defaults', - '_inherits', - '_constraints', - '_sql_constraints', - ): - 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) + cls = type(cls._name, (cls, parent_class), {}) obj = object.__new__(cls) obj.__init__(pool) diff --git a/trytond/wizard/wizard.py b/trytond/wizard/wizard.py index 6e40f6e60a..e35daec5e7 100644 --- a/trytond/wizard/wizard.py +++ b/trytond/wizard/wizard.py @@ -116,18 +116,7 @@ class Wizard(object): """ if pool.get(cls._name): parent_class = pool.get(cls._name).__class__ - new_states = copy.copy(getattr(pool.get(cls._name), 'states')) - for i in ( - 'actions', - 'result', - ): - new = copy.copy(getattr(new_states, i)) - if hasattr(new, 'update'): - new.update(cls.__dict__.get(i, {})) - else: - new.extend(cls.__dict__.get(i, [])) - new_states[i] = new - cls = type(cls._name, (cls, parent_class), {'states': new_states}) + cls = type(cls._name, (cls, parent_class), {}) obj = object.__new__(cls) obj.__init__(pool, pool_obj)