Skip to content

[17.0][FIX] auditlog: swap out tocompute in ThrowAwayCache as well - #3408

Merged
OCA-git-bot merged 1 commit into
OCA:17.0from
StefanRijnhart:17.0-auditlog-fix_field_computes
Oct 8, 2025
Merged

[17.0][FIX] auditlog: swap out tocompute in ThrowAwayCache as well#3408
OCA-git-bot merged 1 commit into
OCA:17.0from
StefanRijnhart:17.0-auditlog-fix_field_computes

Conversation

@StefanRijnhart

@StefanRijnhart StefanRijnhart commented Oct 6, 2025

Copy link
Copy Markdown
Member

Port of #3407

Steps to Reproduce:

Install auditlog and purchase_tier_validation. Create an auditlog rule on the Tier Exception model. Create a new tier exception record for the purchase order model without any fields. In an export, check the value for the stored computed field model_name.

Desired outcome:

The value for model_name is 'purchase.order'.

Actual outcome:

There is no value for the stored computed field model_name. When trying to edit the Fields field, which depends on a valid value for this field, an error occurs saying 'Compute method failed to assign
tier.validation.exception(1,).valid_model_field_ids'.

Analysis:

When read is executed under the scope of the new ThrowAwayCache decorator (#3374), recomputes may be performed and dequeued from self.env.cache.transaction.tocompute. To make sure the recomputed values still end up in the non-volatile as well, we need to preserve the tocompute attribute from the original transaction.

@StefanRijnhart StefanRijnhart changed the title [FIX] auditlog: swap out tocompute in ThrowAwayCache as well [17.0][FIX] auditlog: swap out tocompute in ThrowAwayCache as well Oct 6, 2025
@StefanRijnhart
StefanRijnhart force-pushed the 17.0-auditlog-fix_field_computes branch 2 times, most recently from 983bbf9 to 4204f16 Compare October 6, 2025 14:27
Steps to Reproduce:

Install auditlog and purchase_tier_validation. Create an auditlog rule on
the Tier Exception model. Create a new tier exception record for the purchase
order model without any fields. In an export, check the value for the stored
computed field `model_name`.

Desired outcome:

The value for `model_name` is 'purchase.order'.

Actual outcome:

There is no value for the stored computed field `model_name`. When trying to
edit the `Fields` model, which depends on a valid value for this field, an error
occurs saying 'Compute method failed to assign
tier.validation.exception(1,).valid_model_field_ids'.

Analysis:

When `read` is executed under the scope of the new `ThrowAwayCache` decorator
(OCA#3374), recomputes may be performed and dequeued from
`self.env.cache.transaction.tocompute`. To make sure the recomputed values still
end up in the non-volatile as well, we need to preserve the tocompute attribute
from the original transaction.

@pedrobaeza pedrobaeza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fast-tracking as it has been merged for the rest of the branches:

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

On my way to merge this fine PR!
Prepared branch 17.0-ocabot-merge-pr-3408-by-pedrobaeza-bump-patch, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit 3e6549c into OCA:17.0 Oct 8, 2025
9 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 39401b0. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants