Change Pool into a Singleton

This commit is contained in:
Cédric Krier committed 2011-07-03 13:19:07 +02:00
1 parent 5d21240f94
commit 5f5a799ac6
2 files changed
+12 -10

No files matched your search

+4 -3
View File
@@ -1,6 +1,7 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
from trytond.model import ModelView, ModelSQL, fields
from trytond.pool import Pool
class Allocation(ModelSQL, ModelView):
@@ -19,7 +20,7 @@ class Allocation(ModelSQL, ModelView):
return 100
def write(self, ids, values):
work_obj = self.pool.get('project.work')
work_obj = Pool().get('project.work')
res = super(Allocation, self).write(ids, values)
if isinstance(ids, (int, long)):
@@ -36,14 +37,14 @@ class Allocation(ModelSQL, ModelView):
return res
def create(self, values):
work_obj = self.pool.get('project.work')
work_obj = Pool().get('project.work')
allocation_id = super(Allocation, self).create(values)
allocation = self.browse(allocation_id)
work_obj.reset_leveling(allocation.work.id)
work_obj.compute_dates(allocation.work.id)
def delete(self, ids):
work_obj = self.pool.get('project.work')
work_obj = Pool().get('project.work')
allocations = self.browse(ids)
work_ids = [a.work.id for a in allocations]
res = super(Allocation, self).delete(ids)
+8 -7
View File
@@ -7,6 +7,7 @@ from trytond.model import ModelView, ModelSQL, fields
from trytond.wizard import Wizard
from trytond.pyson import Eval, Not, Equal
from trytond.transaction import Transaction
from trytond.pool import Pool
def intfloor(x):
@@ -86,7 +87,7 @@ class Work(ModelSQL, ModelView):
:return: a dictionary with all field names as key and
a dictionary as value with id as key
'''
req_ref_obj = self.pool.get('res.request.reference')
req_ref_obj = Pool().get('res.request.reference')
cursor = Transaction().cursor
@@ -171,8 +172,8 @@ class Work(ModelSQL, ModelView):
return res
def set_function_fields(self, ids, name, value):
request_obj = self.pool.get('res.request')
req_ref_obj = self.pool.get('res.request.reference')
request_obj = Pool().get('res.request')
req_ref_obj = Pool().get('res.request.reference')
if name == 'requests':
works = self.browse(ids)
@@ -654,7 +655,7 @@ class PredecessorSuccessor(ModelSQL):
ondelete='CASCADE', required=True, select=1)
def write(self, ids, values):
work_obj = self.pool.get('project.work')
work_obj = Pool().get('project.work')
res = super(PredecessorSuccessor, self).write(ids, values)
for work_id in values.itervalues():
@@ -664,7 +665,7 @@ class PredecessorSuccessor(ModelSQL):
return res
def delete(self, ids):
work_obj = self.pool.get('project.work')
work_obj = Pool().get('project.work')
if isinstance(ids, (int, long)):
ids = [ids]
@@ -689,7 +690,7 @@ class PredecessorSuccessor(ModelSQL):
return res
def create(self, values):
work_obj = self.pool.get('project.work')
work_obj = Pool().get('project.work')
ps_id = super(PredecessorSuccessor, self).create(values)
pred_succ = self.browse(ps_id)
@@ -718,7 +719,7 @@ class Leveling(Wizard):
}
def _leveling(self, data):
work_obj = self.pool.get('project.work')
work_obj = Pool().get('project.work')
work_obj.create_leveling(data['id'])
return {}