8000 [FIX] base_multi_image: Access Error by erlinberg · Pull Request #3285 · OCA/server-tools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[FIX] base_multi_image: Access Error #3285

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
wants to merge 1 commit into
base: 16.0
Choose a base branch
from

Conversation

erlinberg
Copy link

I encountered an AccessError when a non-admin user tries to access a base_multi_image form or tree view or when any model that inherits from base_multi_image is used. This error happens because the owner_ref_id field computation tries to access the ir.model table without sufficient permissions.

To fix this, I added .sudo() to the _selection_owner_ref_id method to ensure the system has the necessary access rights to read from ir.model, regardless of the user's permissions.

@erlinberg
Copy link
Author

@legalsylvain @ivs-cetmix @Aldeigja please review

@ivs-cetmix
Copy link
Member

@erlinberg thank you for you contribution! Did you manage to reproduce this error on the runboat? I checked it on 14.0 with "Product Multi Image" and looks like there are some other access error being raised.

@erlinberg
Copy link
Author

@ivs-cetmix I reproduced the issue on runboat by adding a simple view action called "Product Images Demo Action" to Sales, which includes a tree and form view for base_multi_image.image. I applied an owner domain and linked it to a menu item called "Product Images Demo", with access rights set for non-admin users.

When opened by the demo user, an AccessError is raised because regular users don’t have access to the ir.model records that base_multi_image.image relies on.

http://oca-server-tools-16-0-57c6d831b62d.runboat.odoo-community.org/

image

@ivs-cetmix
Copy link
Member

@erlinberg makes sense, thank you! Please also add a more complete description to the commit message. Eg:

[FIX] base_multi_image: Access Error

**Before this commit**

Access error is raised if user who doesn't have access to system settings tries to open a record that contains multiple images.

**After this commit**

Access error is not raised any longer because model list is fetched using `sudo`.

Copy link
Member
@ivs-cetmix ivs-cetmix left a comment

Choose a reason for hiding this comment

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

Code review LGTM

@ivs-cetmix
Copy link
Member

@erlinberg please also add tests that cover your change.

@erlinberg erlinberg force-pushed the 16.0-base-multi-image-fix-access-error branch from 17c5f88 to 769f69b Compare May 26, 2025 07:03
**Before this commit**

Access error is raised if user who doesn't have access to system settings tries to open a record that contains multiple images.

**After this commit**

Access error is not raised any longer because model list is fetched using `sudo`.
@erlinberg erlinberg force-pushed the 16.0-base-multi-image-fix-access-error branch from 769f69b to 4eee504 Compare May 26, 2025 07:20
@erlinberg
Copy link
Author

@ivs-cetmix Updated the commit message and added tests. Thanks!

@ivs-cetmix
Copy link
Member

@ivs-cetmix Updated the commit message and added tests. Thanks!

@erlinberg thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0