[REF] osv:
- make it more explcicit in osv_pool that afreshly instanciated object is added to the pool - osv_pool.init_set() is called just once with False, so no need to check if it is the first time it is called or if is called with True - and rename it in do_parent_store as it is what it does. bzr revid: vmt@openerp.com-20110526210532-a8i91shptz5h4k48
This commit is contained in:
@@ -90,7 +90,7 @@ class RegistryManager(object):
|
||||
|
||||
cr = db.cursor()
|
||||
try:
|
||||
pool.init_set(cr, False)
|
||||
pool.do_parent_store(cr)
|
||||
pool.get('ir.actions.report.xml').register_all(cr)
|
||||
cr.commit()
|
||||
finally:
|
||||
|
||||
@@ -639,7 +639,6 @@ class orm_template(object):
|
||||
|
||||
def __init__(self, pool, cr):
|
||||
""" Initialize a model and make it part of the given registry."""
|
||||
pool.add(self._name, self)
|
||||
self.pool = pool
|
||||
|
||||
if not self._name and not hasattr(self, '_inherit'):
|
||||
|
||||
+10
-16
@@ -117,7 +117,7 @@ class object_proxy(netsvc.Service):
|
||||
return tr(src, 'code')
|
||||
|
||||
try:
|
||||
if not pooler.get_pool(dbname)._ready:
|
||||
if pooler.get_pool(dbname)._init:
|
||||
raise except_osv('Database not ready', 'Currently, this database is not fully loaded and can not be used.')
|
||||
return f(self, dbname, *args, **kwargs)
|
||||
except orm.except_orm, inst:
|
||||
@@ -212,25 +212,16 @@ class osv_pool(object):
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._ready = False
|
||||
self.obj_pool = {} # model name/model instance mapping
|
||||
self._sql_error = {}
|
||||
self._store_function = {}
|
||||
self._init = True
|
||||
self._init_parent = {}
|
||||
|
||||
def init_set(self, cr, mode):
|
||||
different = mode != self._init
|
||||
if different:
|
||||
if mode:
|
||||
self._init_parent = {}
|
||||
if not mode:
|
||||
for o in self._init_parent:
|
||||
self.get(o)._parent_store_compute(cr)
|
||||
self._init = mode
|
||||
|
||||
self._ready = True
|
||||
return different
|
||||
def do_parent_store(self, cr):
|
||||
for o in self._init_parent:
|
||||
self.get(o)._parent_store_compute(cr)
|
||||
self._init = False
|
||||
|
||||
def obj_list(self):
|
||||
""" Return the list of model names in this registry."""
|
||||
@@ -249,9 +240,12 @@ class osv_pool(object):
|
||||
|
||||
res = []
|
||||
|
||||
# instanciate classes registered through their constructor
|
||||
# Instanciate classes registered through their constructor and
|
||||
# add them to the pool.
|
||||
for klass in module_class_list.get(module, []):
|
||||
res.append(klass.createInstance(self, module, cr))
|
||||
inst = klass.createInstance(self, module, cr)
|
||||
self.add(inst._name, inst)
|
||||
res.append(inst)
|
||||
|
||||
return res
|
||||
|
||||
|
||||
Reference in New Issue
Block a user