Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][FIX] auditlog: registry propagation #3088

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 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 @@
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 @@
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 @@
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,9 @@
if isinstance(fieldvalue, models.BaseModel) and not fieldvalue:
vals[fieldname] = False
return vals_list

def _update_registry(self):
"""Update the registry after a modification on automation rules."""
gurneyalex marked this conversation as resolved.
Show resolved Hide resolved
if self.env.registry.ready and not self.env.context.get("import_file"):
# notify other workers
self.env.registry.registry_invalidated = True

Check warning on line 743 in auditlog/models/rule.py

View check run for this annotation

Codecov / codecov/patch

auditlog/models/rule.py#L743

Added line #L743 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it something compatible on Odoo < 17.0 that should be backported?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems at least compatible with Odoo 16.0, didn't checked previous versions.

Loading