Browse Source

[RFR] Rewrite the cache failed hit lookup method

pull/1049/head
Eric Lembregts 7 years ago
committed by Holger Brunn
parent
commit
8a79d2a769
  1. 15
      auditlog/models/rule.py

15
auditlog/models/rule.py

@ -472,20 +472,17 @@ class AuditlogRule(models.Model):
http_session_model = self.env['auditlog.http.session'] http_session_model = self.env['auditlog.http.session']
for res_id in res_ids: for res_id in res_ids:
model_model = self.env[res_model] model_model = self.env[res_model]
# Do extra check for active_model situations where res_model
# Do an extra check for active_model situations where res_model
# is not preloaded in auditlog model_cache # is not preloaded in auditlog model_cache
model_id = self.pool._auditlog_model_cache.get(res_model, False)
if not model_id:
model = self.env['ir.model'].search([
('model', '=', res_model)])
if model:
model_id = model.id
self.pool._auditlog_model_cache[res_model] = model_id
if not self.pool._auditlog_model_cache.get(res_model):
self.pool._auditlog_model_cache[res_model] = \
self.env['ir.model'].search([
('model', '=', res_model)]).id
name = model_model.browse(res_id).name_get() name = model_model.browse(res_id).name_get()
res_name = name and name[0] and name[0][1] res_name = name and name[0] and name[0][1]
vals = { vals = {
'name': res_name, 'name': res_name,
'model_id': model_id,
'model_id': self.pool._auditlog_model_cache[res_model],
'res_id': res_id, 'res_id': res_id,
'method': method, 'method': method,
'user_id': uid, 'user_id': uid,

Loading…
Cancel
Save