[FIX] api: clear environments on module installation
This commit is contained in:
parent
9bf8dea569
commit
1c6c289f7b
|
@ -27,7 +27,7 @@ import types
|
|||
|
||||
import openerp
|
||||
from openerp import SUPERUSER_ID
|
||||
from openerp import models, tools
|
||||
from openerp import models, tools, api
|
||||
from openerp.modules.registry import RegistryManager
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.osv.orm import BaseModel, Model, MAGIC_COLUMNS, except_orm
|
||||
|
@ -181,6 +181,7 @@ class ir_model(osv.osv):
|
|||
# only reload pool for normal unlink. For module uninstall the
|
||||
# reload is done independently in openerp.modules.loading
|
||||
cr.commit() # must be committed before reloading registry in new cursor
|
||||
api.Environment.reset()
|
||||
RegistryManager.new(cr.dbname)
|
||||
RegistryManager.signal_registry_change(cr.dbname)
|
||||
|
||||
|
|
|
@ -494,6 +494,7 @@ class module(osv.osv):
|
|||
function(cr, uid, ids, context=context)
|
||||
|
||||
cr.commit()
|
||||
api.Environment.reset()
|
||||
registry = openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)
|
||||
|
||||
config = registry['res.config'].next(cr, uid, [], context=context) or {}
|
||||
|
|
|
@ -101,6 +101,7 @@ class base_module_upgrade(osv.osv_memory):
|
|||
ir_module.download(cr, uid, ids, context=context)
|
||||
cr.commit() # save before re-creating cursor below
|
||||
|
||||
openerp.api.Environment.reset()
|
||||
openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)
|
||||
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
|
|
@ -693,6 +693,13 @@ class Environment(object):
|
|||
finally:
|
||||
release_local(cls._local)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
""" Clear the set of environments.
|
||||
This may be useful when recreating a registry inside a transaction.
|
||||
"""
|
||||
cls._local.environments = Environments()
|
||||
|
||||
def __new__(cls, cr, uid, context):
|
||||
assert context is not None
|
||||
args = (cr, uid, context)
|
||||
|
|
|
@ -432,6 +432,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
|
|||
# modules to remove next time
|
||||
cr.commit()
|
||||
_logger.info('Reloading registry once more after uninstalling modules')
|
||||
openerp.api.Environment.reset()
|
||||
return openerp.modules.registry.RegistryManager.new(cr.dbname, force_demo, status, update_module)
|
||||
|
||||
# STEP 7: verify custom views on every model
|
||||
|
|
Loading…
Reference in New Issue