Change Pool into a Singleton

This commit is contained in:
Cédric Krier committed 2011-07-03 13:18:48 +02:00
1 parent 017ee0a62e
commit d261a0e6d7
1 file changed
+11 -10
+11 -10
View File
@@ -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()