Skip to content

[20.0][MIG] document_page_access_group: Migration to 20.0 - #670

Open
bm1-phillip wants to merge 13 commits into
OCA:20.0from
BM1-de:20.0-mig-document_page_access_group
Open

bm1-phillip wants to merge 13 commits into
OCA:20.0from
BM1-de:20.0-mig-document_page_access_group

Conversation

@bm1-phillip

@bm1-phillip bm1-phillip commented Nov 14, 2026 •

Copy link
Copy Markdown

Migration of document_page_access_group to 20.0.

This one needs more than the usual changes, because the module relied on group-specific
ir.rule records to restrict what document_page grants. With ir.access, permissions
(records with a group) are OR-ed together, so adding a permission with a domain no longer
restricts anything while the unrestricted permission of document_page is active.

What the module does now (same pattern as hr_recruitment or sale_timesheet in Odoo core):

  • It disables document_page.document_page_user and document_page.document_page_editor.
  • It adds its own permissions for the same groups and operations, carrying the groups/users
    domain of the former rule (security/ir.access.csv).
  • Managers keep full access through document_page.document_page_manager, so the former
    "full access" rule is not needed any more.
  • An uninstall_hook enables the two permissions of document_page again.
  • On upgrade from 19.0, a post-migration script disables the two permissions as well: security/security.xml is a noupdate block, which Odoo skips when the records already exist, and document_page creates them active before this module is updated.

Other changes:

  • Tests: _test_user_groups = None, plus a test for the uninstall hook.
  • Removed the redundant string of groups_id (pylint attribute-string-redundant).

The domain itself is unchanged, including user.group_ids (explicitly assigned groups only).
I can follow up with a separate PR if user.all_group_ids is preferred.

Checked on a fresh Odoo 20 database with a reader, an editor and a manager: pages without
groups are visible to everyone, pages with a group only to its members, editors can only
modify what they can read, managers see and edit everything.

Migration issue: #650

🤖 Generated with Claude Code

@oca-cla-bot

oca-cla-bot Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@OCA-git-bot OCA-git-bot added mod:document_page_access_group Module document_page_access_group series:20.0 labels Nov 14, 2026
@bm1-phillip
bm1-phillip force-pushed the 20.0-mig-document_page_access_group branch from 81474d2 to 74f0efe Compare November 14, 2026 09:01
@victoralmau

Copy link
Copy Markdown
Member

Please, cherry-pick #663 to commit history before pre-commit migration commit and squash administrative commits.

@victoralmau victoralmau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In my opinion, all of this can be simplified a lot:

  • No migration script is needed
  • No uninstall_hook is needed
  • The security.xml file is not needed
  • The ir.access.csv file should ONLY override the domain for the document_page rules we need—nothing else.

@bm1-phillip
bm1-phillip force-pushed the 20.0-mig-document_page_access_group branch from 74f0efe to 03b9f8a Compare November 30, 2026 11:46
@bm1-phillip

Copy link
Copy Markdown
Author

Thanks for the review, Víctor. I've simplified it as suggested: there is no migration script and no security.xml anymore, and ir.access.csv now only overrides the domain of document_page.document_page_user and document_page.document_page_editor. I also cherry-picked #663 before the pre-commit commit and squashed the administrative commits. I kept one small uninstall_hook, though: the overridden domain stays on the document_page records after this module is uninstalled, but it refers to groups_id and user_ids, which are removed together with the module. I tested this: without the hook, every document user gets "Invalid field document.page.groups_id" when opening pages after the uninstall, until document_page is updated by hand. The hook only resets the domain of these two records, and it is covered by a test. If you'd prefer to handle the uninstall differently, I'm happy to change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:document_page_access_group Module document_page_access_group series:20.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants