[IMP] decimal_precision, ir_rule, ir_ui_view: simplify ormcache invalidation
The patch speeds up the cache invalidation in the registry, and make most models use the generic method `clear_caches` instead of specific `clear_cache` methods.
This commit is contained in:
@@ -46,23 +46,22 @@ class decimal_precision(orm.Model):
|
||||
return res[0] if res else 2
|
||||
|
||||
def clear_cache(self, cr):
|
||||
"""clear cache and update models. Notify other workers to restart their registry."""
|
||||
self.precision_get.clear_cache(self)
|
||||
RegistryManager.signal_registry_change(cr.dbname)
|
||||
""" Deprecated, use `clear_caches` instead. """
|
||||
self.clear_caches()
|
||||
|
||||
def create(self, cr, uid, data, context=None):
|
||||
res = super(decimal_precision, self).create(cr, uid, data, context=context)
|
||||
self.clear_cache(cr)
|
||||
self.clear_caches()
|
||||
return res
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
res = super(decimal_precision, self).unlink(cr, uid, ids, context=context)
|
||||
self.clear_cache(cr)
|
||||
self.clear_caches()
|
||||
return res
|
||||
|
||||
def write(self, cr, uid, ids, data, *args, **argv):
|
||||
res = super(decimal_precision, self).write(cr, uid, ids, data, *args, **argv)
|
||||
self.clear_cache(cr)
|
||||
self.clear_caches()
|
||||
return res
|
||||
|
||||
|
||||
|
||||
@@ -144,7 +144,8 @@ class ir_rule(osv.osv):
|
||||
return []
|
||||
|
||||
def clear_cache(self, cr, uid):
|
||||
self._compute_domain.clear_cache(self)
|
||||
""" Deprecated, use `clear_caches` instead. """
|
||||
self.clear_caches()
|
||||
|
||||
def domain_get(self, cr, uid, model_name, mode='read', context=None):
|
||||
dom = self._compute_domain(cr, uid, model_name, mode)
|
||||
@@ -159,15 +160,15 @@ class ir_rule(osv.osv):
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
res = super(ir_rule, self).unlink(cr, uid, ids, context=context)
|
||||
self.clear_cache(cr, uid)
|
||||
self.clear_caches()
|
||||
return res
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
res = super(ir_rule, self).create(cr, uid, vals, context=context)
|
||||
self.clear_cache(cr, uid)
|
||||
self.clear_caches()
|
||||
return res
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
res = super(ir_rule, self).write(cr, uid, ids, vals, context=context)
|
||||
self.clear_cache(cr,uid)
|
||||
self.clear_caches()
|
||||
return res
|
||||
|
||||
@@ -320,7 +320,7 @@ class view(osv.osv):
|
||||
if not values.get('name'):
|
||||
values['name'] = "%s %s" % (values.get('model'), values['type'])
|
||||
|
||||
self.clear_cache()
|
||||
self.clear_caches()
|
||||
return super(view, self).create(
|
||||
cr, uid,
|
||||
self._compute_defaults(cr, uid, values, context=context),
|
||||
@@ -343,7 +343,7 @@ class view(osv.osv):
|
||||
if custom_view_ids:
|
||||
self.pool.get('ir.ui.view.custom').unlink(cr, uid, custom_view_ids)
|
||||
|
||||
self.clear_cache()
|
||||
self.clear_caches()
|
||||
ret = super(view, self).write(
|
||||
cr, uid, ids,
|
||||
self._compute_defaults(cr, uid, vals, context=context),
|
||||
@@ -956,7 +956,8 @@ class view(osv.osv):
|
||||
return self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, xml_id, raise_if_not_found=True)
|
||||
|
||||
def clear_cache(self):
|
||||
self._read_template.clear_cache(self)
|
||||
""" Deprecated, use `clear_caches` instead. """
|
||||
self.clear_caches()
|
||||
|
||||
def _contains_branded(self, node):
|
||||
return node.tag == 't'\
|
||||
|
||||
@@ -199,6 +199,7 @@ class Registry(Mapping):
|
||||
This clears the caches associated to methods decorated with
|
||||
``tools.ormcache`` or ``tools.ormcache_multi`` for all the models.
|
||||
"""
|
||||
self.cache.clear()
|
||||
for model in self.models.itervalues():
|
||||
model.clear_caches()
|
||||
# Special case for ir_ui_menu which does not use openerp.tools.ormcache.
|
||||
|
||||
Reference in New Issue
Block a user