[16.0][FIX]base: avoid invalid access error in onchange() when editing user#1294
Open
[16.0][FIX]base: avoid invalid access error in onchange() when editing user#1294
Conversation
6850e8a to
7c21777
Compare
HekkiMelody
approved these changes
Apr 28, 2025
7c21777 to
90403fe
Compare
HekkiMelody
approved these changes
May 8, 2025
|
@OCA/backport-maintainers Can this be merged? It's a small fix that could potentially impact a lot of users. |
Member
|
Steps to reproduce the problem? A change like this in the framework seems very risky to be merged, specially if Odoo, being 16.0 a supported version, is not doing it. |
… user Steps to reproduce: ------------------- - install the "hr" module; - remove access rights for "Employees"; - change language on the user profile. Issue: ------ There's an Access Error because we can't read the `private_street` field on the employee that corresponds to the user. Cause: ------ The new version of onchange fetches the record values on the server side, unlike the old version which used the values in the view. In the old version, as we were using view values, this didn't cause any problems, as the values came from a read that which took into account `SELF_READABLE_FIELDS`. Note: We do not have access to the value of the `private_street` field because it is a related field with the attribute `related_sudo=False` and we do not have access rights for the `hr.employee` model. Solution: --------- Use the cache and place the values of the fields in `SELF_READABLE_FIELDS` in it before performing the onchange logic. opw-3664929
When the server-side form view reads its record, the call to web_read() leaves data in cache, which may prevent some access error to be triggered in the first call to onchange(). In order to avoid that, simply clean up the environment like after the other method calls.
90403fe to
036cc9c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Cherry-picked two fixes that avoid Access Error because can't read some fields on the employee that corresponds to the user.
Original PR:
odoo#148997
There was a refactor of class Form between 16.0 and 17.0 versions. The class moved from tests/common.py (16.0) to tests/form.py (17.0), so I just copied the two lines of the fix in
_init_from_valuesmethod.