我遇到了一些rules的问题。有些规则有一天会有效,但第二天就会停止工作。
我考虑到规则不会影响管理员用户。
我想知道是否可以在ir.rule
模型中打印记录器消息以检查当前满足哪些规则域。我正在看模型方法,但我不知道在哪里写它。
答案 0 :(得分:0)
在加载每个视图时,我必须在记录器中编写计算域:
def clear_cache(self, cr, uid):
_logger.warning('-- CACHE CLEARED')
self._compute_domain.clear_cache(self)
def domain_get(self, cr, uid, model_name, mode='read', context=None):
dom = self._compute_domain(cr, uid, model_name, mode)
if dom:
# _where_calc is called as superuser. This means that rules can
# involve objects on which the real uid has no acces rights.
# This means also there is no implicit restriction (e.g. an object
# references another object the user can't see).
_logger.warning('>> MODEL NAME: {}'.format(model_name))
_logger.warning('>> COMPUTED DOMAIN: {}'.format(dom))
query = self.pool[model_name]._where_calc(cr, SUPERUSER_ID, dom, active_test=False)
return query.where_clause, query.where_clause_params, query.tables
return [], [], ['"' + self.pool[model_name]._table + '"']
我意识到只有当他们不在缓存中时才会计算它们。当我更新模块时,缓存被清除。但我仍然不知道为什么有时规则不能很好地运作。