Skip to content

Commit

Permalink
Merge PR #3088 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by sebalix
  • Loading branch information
OCA-git-bot committed Oct 23, 2024
2 parents 6bc276d + 5d2afc0 commit 94d1f29
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions auditlog/models/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import copy

from odoo import _, api, fields, models, modules
from odoo import _, api, fields, models
from odoo.exceptions import UserError

FIELDS_BLACKLIST = [
Expand Down Expand Up @@ -223,7 +223,7 @@ def _revert_methods(self):
delattr(type(model_model), "auditlog_ruled_%s" % method)
updated = True
if updated:
modules.registry.Registry(self.env.cr.dbname).signal_changes()
self._update_registry()

@api.model_create_multi
def create(self, vals_list):
Expand All @@ -236,7 +236,7 @@ def create(self, vals_list):
new_records = super().create(vals_list)
updated = [record._register_hook() for record in new_records]
if any(updated):
modules.registry.Registry(self.env.cr.dbname).signal_changes()
self._update_registry()
return new_records

def write(self, vals):
Expand All @@ -248,7 +248,7 @@ def write(self, vals):
vals.update({"model_name": model.name, "model_model": model.model})
res = super().write(vals)
if self._register_hook():
modules.registry.Registry(self.env.cr.dbname).signal_changes()
self._update_registry()
return res

def unlink(self):
Expand Down Expand Up @@ -735,3 +735,10 @@ def _update_vals_list(self, vals_list):
if isinstance(fieldvalue, models.BaseModel) and not fieldvalue:
vals[fieldname] = False
return vals_list

def _update_registry(self):
"""Force a registry reload after rule change"""
# this code comes from `base_automation` which has a similar need
if self.env.registry.ready and not self.env.context.get("import_file"):
# notify other workers
self.env.registry.registry_invalidated = True

0 comments on commit 94d1f29

Please sign in to comment.