-
-
Notifications
You must be signed in to change notification settings - Fork 437
[16.0][FIX]base: avoid invalid access error in onchange() when editing user #1294
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
Open
quirino95
wants to merge
2
commits into
OCA:16.0
Choose a base branch
from
PyTech-SRL:16.0_onchange_no_access_fields_issue
base: 16.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[16.0][FIX]base: avoid invalid access error in onchange() when editing user #1294
quirino95
wants to merge
2
commits into
OCA:16.0
from
PyTech-SRL:16.0_onchange_no_access_fields_issue
Conversation
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
6850e8a to
7c21777
Compare
aleuffre
approved these changes
Apr 28, 2025
aleuffre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7c21777 to
90403fe
Compare
aleuffre
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
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.