Use groups as key for fields_view_get cache
This permits to not clear the cache when users or actions are modified.
This commit is contained in:
@@ -226,14 +226,12 @@ class ActionKeyword(ModelSQL, ModelView):
|
||||
|
||||
@classmethod
|
||||
def delete(cls, keywords):
|
||||
ModelView._fields_view_get_cache.clear()
|
||||
ModelView._view_toolbar_get_cache.clear()
|
||||
cls._get_keyword_cache.clear()
|
||||
super(ActionKeyword, cls).delete(keywords)
|
||||
|
||||
@classmethod
|
||||
def create(cls, vlist):
|
||||
ModelView._fields_view_get_cache.clear()
|
||||
ModelView._view_toolbar_get_cache.clear()
|
||||
cls._get_keyword_cache.clear()
|
||||
new_vlist = []
|
||||
@@ -248,7 +246,6 @@ class ActionKeyword(ModelSQL, ModelView):
|
||||
for keywords, values in zip(actions, actions):
|
||||
args.extend((keywords, cls._convert_vals(values)))
|
||||
super(ActionKeyword, cls).write(*args)
|
||||
ModelView._fields_view_get_cache.clear()
|
||||
ModelView._view_toolbar_get_cache.clear()
|
||||
cls._get_keyword_cache.clear()
|
||||
|
||||
@@ -390,7 +387,6 @@ class ActionMixin(ModelSQL):
|
||||
@classmethod
|
||||
def create(cls, vlist):
|
||||
pool = Pool()
|
||||
ModelView._fields_view_get_cache.clear()
|
||||
ModelView._view_toolbar_get_cache.clear()
|
||||
Action = pool.get('ir.action')
|
||||
ir_action = cls.__table__()
|
||||
@@ -435,14 +431,12 @@ class ActionMixin(ModelSQL):
|
||||
pool = Pool()
|
||||
ActionKeyword = pool.get('ir.action.keyword')
|
||||
super(ActionMixin, cls).write(records, values, *args)
|
||||
ModelView._fields_view_get_cache.clear()
|
||||
ModelView._view_toolbar_get_cache.clear()
|
||||
ActionKeyword._get_keyword_cache.clear()
|
||||
|
||||
@classmethod
|
||||
def delete(cls, records):
|
||||
pool = Pool()
|
||||
ModelView._fields_view_get_cache.clear()
|
||||
ModelView._view_toolbar_get_cache.clear()
|
||||
Action = pool.get('ir.action')
|
||||
actions = [x.action for x in records]
|
||||
|
||||
@@ -226,7 +226,10 @@ class ModelView(Model):
|
||||
- fields: a dictionary with the definition of each field in the view
|
||||
- field_childs: the name of the childs field for tree
|
||||
'''
|
||||
key = (cls.__name__, view_id, view_type, level)
|
||||
pool = Pool()
|
||||
User = pool.get('res.user')
|
||||
|
||||
key = (User.get_groups(), cls.__name__, view_id, view_type, level)
|
||||
result = cls._fields_view_get_cache.get(key)
|
||||
if result:
|
||||
return result
|
||||
|
||||
@@ -64,8 +64,6 @@ class Group(DeactivableMixin, tree(), ModelSQL, ModelView):
|
||||
pool = Pool()
|
||||
# Restart the cache for get_groups
|
||||
pool.get('res.user')._get_groups_cache.clear()
|
||||
# Restart the cache for view
|
||||
ModelView._fields_view_get_cache.clear()
|
||||
|
||||
@classmethod
|
||||
def copy(cls, groups, default=None):
|
||||
|
||||
@@ -414,8 +414,6 @@ class User(avatar_mixin(100, 'login'), DeactivableMixin, ModelSQL, ModelView):
|
||||
if cls.__name__ in cache:
|
||||
for user in all_users:
|
||||
cache[cls.__name__].pop(user.id, None)
|
||||
# Restart the cache
|
||||
ModelView._fields_view_get_cache.clear()
|
||||
|
||||
@classmethod
|
||||
def delete(cls, users):
|
||||
@@ -1017,8 +1015,6 @@ class UserGroup(ModelSQL):
|
||||
pool = Pool()
|
||||
# Restart the cache for get_groups
|
||||
pool.get('res.user')._get_groups_cache.clear()
|
||||
# Restart the cache for view
|
||||
ModelView._fields_view_get_cache.clear()
|
||||
return records
|
||||
|
||||
@classmethod
|
||||
@@ -1027,8 +1023,6 @@ class UserGroup(ModelSQL):
|
||||
pool = Pool()
|
||||
# Restart the cache for get_groups
|
||||
pool.get('res.user')._get_groups_cache.clear()
|
||||
# Restart the cache for view
|
||||
ModelView._fields_view_get_cache.clear()
|
||||
|
||||
@classmethod
|
||||
def delete(cls, groups):
|
||||
@@ -1036,8 +1030,6 @@ class UserGroup(ModelSQL):
|
||||
pool = Pool()
|
||||
# Restart the cache for get_groups
|
||||
pool.get('res.user')._get_groups_cache.clear()
|
||||
# Restart the cache for view
|
||||
ModelView._fields_view_get_cache.clear()
|
||||
|
||||
@classmethod
|
||||
def user_group_all_table(cls):
|
||||
|
||||
Reference in New Issue
Block a user