From d261a0e6d7e8c8d1fdb5b21ea45a6cf4426a897d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 3 Jul 2011 13:18:48 +0200 Subject: [PATCH] Change Pool into a Singleton --- invoice.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/invoice.py b/invoice.py index b85c5f3325..fdac2dca0a 100644 --- a/invoice.py +++ b/invoice.py @@ -4,6 +4,7 @@ from __future__ import with_statement from trytond.model import ModelView, ModelSQL, fields from trytond.pyson import Not, Equal, Eval from trytond.transaction import Transaction +from trytond.pool import Pool class InvoiceLine(ModelSQL, ModelView): @@ -16,14 +17,14 @@ class InvoiceLine(ModelSQL, ModelView): }) def _view_look_dom_arch(self, tree, type, field_children=None): - analytic_account_obj = self.pool.get('analytic_account.account') + analytic_account_obj = Pool().get('analytic_account.account') analytic_account_obj.convert_view(tree) arch, fields = super(InvoiceLine, self)._view_look_dom_arch(tree, type, field_children=field_children) return arch, fields def fields_get(self, fields_names=None): - analytic_account_obj = self.pool.get('analytic_account.account') + analytic_account_obj = Pool().get('analytic_account.account') res = super(InvoiceLine, self).fields_get(fields_names) @@ -35,7 +36,7 @@ class InvoiceLine(ModelSQL, ModelView): return res def read(self, ids, fields_names=None): - selection_obj = self.pool.get('analytic_account.account.selection') + selection_obj = Pool().get('analytic_account.account.selection') int_id = False if isinstance(ids, (int, long)): @@ -85,7 +86,7 @@ class InvoiceLine(ModelSQL, ModelView): return res def create(self, vals): - selection_obj = self.pool.get('analytic_account.account.selection') + selection_obj = Pool().get('analytic_account.account.selection') vals = vals.copy() selection_vals = {} for field in vals.keys(): @@ -102,7 +103,7 @@ class InvoiceLine(ModelSQL, ModelView): return super(InvoiceLine, self).create(vals) def write(self, ids, vals): - selection_obj = self.pool.get('analytic_account.account.selection') + selection_obj = Pool().get('analytic_account.account.selection') vals = vals.copy() if isinstance(ids, (int, long)): ids = [ids] @@ -143,7 +144,7 @@ class InvoiceLine(ModelSQL, ModelView): return super(InvoiceLine, self).write(ids, vals) def delete(self, ids): - selection_obj = self.pool.get('analytic_account.account.selection') + selection_obj = Pool().get('analytic_account.account.selection') if isinstance(ids, (int, long)): ids = [ids] @@ -158,7 +159,7 @@ class InvoiceLine(ModelSQL, ModelView): return res def copy(self, ids, default=None): - selection_obj = self.pool.get('analytic_account.account.selection') + selection_obj = Pool().get('analytic_account.account.selection') new_ids = super(InvoiceLine, self).copy(ids, default=default) @@ -203,21 +204,21 @@ class Account(ModelSQL, ModelView): _name = 'analytic_account.account' def delete(self, ids): - account_invoice_line_obj = self.pool.get('account.invoice.line') + account_invoice_line_obj = Pool().get('account.invoice.line') res = super(Account, self).delete(ids) # Restart the cache on the fields_view_get method of account.invoice.line account_invoice_line_obj.fields_view_get.reset() return res def create(self, vals): - account_invoice_line_obj = self.pool.get('account.invoice.line') + account_invoice_line_obj = Pool().get('account.invoice.line') res = super(Account, self).create(vals) # Restart the cache on the fields_view_get method of account.invoice.line account_invoice_line_obj.fields_view_get.reset() return res def write(self, ids, vals): - account_invoice_line_obj = self.pool.get('account.invoice.line') + account_invoice_line_obj = Pool().get('account.invoice.line') res = super(Account, self).write(ids, vals) # Restart the cache on the fields_view_get method of account.invoice.line account_invoice_line_obj.fields_view_get.reset()