I am having some issues with some rules. Some rules that are working one day, but they stop working the next day.
I am taking into account that the rules does not affect to the Administrator user.
I am wondering if I could print a logger message in the ir.rule
model to check which rule domains are currently satisfied. I was taking a look to the model methods but I am not sure where to write it.
Well I got to write the computed domains in the logger when each view is loaded:
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 + '"']
I realised they are only computed when they are not in the cache. When I update the module the cache is cleared. But I still don´t know why sometimes rules are not working well.