Repository navigation
[20.0][MIG] document_page_access_group: Migration to 20.0 - #670
bm1-phillip wants to merge 13 commits into
Conversation
81474d2 to
74f0efe
Compare
|
Please, cherry-pick #663 to commit history before pre-commit migration commit and squash administrative commits. |
victoralmau
left a comment
There was a problem hiding this comment.
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.
… instead of cr As stated in https://github.com/OCA/openupgradelib/blob/master/openupgradelib/openupgrade.py#L297, the param should `env`, instead of the cursor
The pylint-odoo version of template v1.48 makes attribute-string-redundant (W8113) mandatory. The removed labels are the ones Odoo already generates from the field name, so the UI does not change.
74f0efe to
03b9f8a
Compare
|
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. |
Migration of
document_page_access_groupto 20.0.This one needs more than the usual changes, because the module relied on group-specific
ir.rulerecords to restrict whatdocument_pagegrants. Withir.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_pageis active.What the module does now (same pattern as
hr_recruitmentorsale_timesheetin Odoo core):document_page.document_page_useranddocument_page.document_page_editor.domain of the former rule (
security/ir.access.csv).document_page.document_page_manager, so the former"full access" rule is not needed any more.
uninstall_hookenables the two permissions ofdocument_pageagain.security/security.xmlis a noupdate block, which Odoo skips when the records already exist, anddocument_pagecreates them active before this module is updated.Other changes:
_test_user_groups = None, plus a test for the uninstall hook.stringofgroups_id(pylintattribute-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_idsis 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