Skip to content

[18.0][FIX] auditlog: swap out tocompute in ThrowAwayCache as well - #3407

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

OCA-git-bot merged 1 commit into
OCA:18.0from
StefanRijnhart:18.0-auditlog-fix_field_computes

Conversation

@StefanRijnhart

@StefanRijnhart StefanRijnhart commented Oct 6, 2025

Copy link
Copy Markdown
Member

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 recompute in ThrowAwayCache as well [FIX] auditlog: swap out tocompute in ThrowAwayCache as well Oct 6, 2025
@StefanRijnhart
StefanRijnhart force-pushed the 18.0-auditlog-fix_field_computes branch from 52f6b80 to 462edf3 Compare October 6, 2025 13:02
@StefanRijnhart StefanRijnhart changed the title [FIX] auditlog: swap out tocompute in ThrowAwayCache as well [18.0][FIX] auditlog: swap out tocompute in ThrowAwayCache as well Oct 6, 2025
@StefanRijnhart
StefanRijnhart force-pushed the 18.0-auditlog-fix_field_computes branch from 462edf3 to 2c3042b Compare October 6, 2025 13:47
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.
@StefanRijnhart
StefanRijnhart force-pushed the 18.0-auditlog-fix_field_computes branch from 2c3042b to 2c75742 Compare October 6, 2025 14:26

@LoisRForgeFlow LoisRForgeFlow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good 👍 We have tested and indeed fixes the problem

@pedrobaeza

Copy link
Copy Markdown
Member

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 18.0-ocabot-merge-pr-3407-by-pedrobaeza-bump-patch, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit 3ace41f into OCA:18.0 Oct 8, 2025
7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

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

@StefanRijnhart

Copy link
Copy Markdown
Member Author

Thanks for the quick follow-up. Can this one be merged as well? #3408

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.

6 participants