Skip to content
Snippets Groups Projects
Commit 6873803f authored by Richard deMeester's avatar Richard deMeester Committed by Nicolas Lempereur
Browse files

[FIX] fields.py: no lose _protected on related_sudo


If we are:

- not in sudo
- computing a compute field
- using a related_sudo field

we want to keep the env._protected dictionary when we `sudo` to get the
related value, because if we don't we lost the protection of field we
were currently computing.

Original description:

> When a "computed value A" relies on "computed value B" and
> "computed value B" needs a related value (e.g. product.product from
> product.template), then "_compute_related" in api.py will copy the
> cache if the user is not superuser.
>
> The cache is not copying the values in "_protected", causing
> "modified_draft" in fields.py to incorrectly invalidate the cache for
> already computed values which should be protected by their inclusion
> in "_protected".

note: the added test does not fail without this change, it is just a
partial backport of 12.0 to ensure what worked still worked.

opw-2146097
closes #40916
closes #42714

closes odoo/odoo#43376

X-original-commit: 97bdb7a668b5c4c9ad759fc795e859207b6ed28d
Signed-off-by: default avatarNicolas Lempereur (nle) <nle@odoo.com>
Co-authored-by: default avatarNicolas Lempereur <nle@odoo.com>
parent eb71d25c
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment