From f5d6343bb30a9ce7ebc5a888f75a1f9f9ef0d57b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Fri, 4 Sep 2026 10:20:31 +0200 Subject: [PATCH 1/2] [FIX] dms: Taking archived users into account MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use Case Example: - Create an archived user (an employee’s user account that will be activated in the future) - Create a group that explicitly includes the user created earlier (this is done indirectly using `hr_dms_field`) - The `users` field does not contain this user TT64366 --- dms/README.rst | 128 ++++++++++---------- dms/__manifest__.py | 2 +- dms/migrations/18.0.1.2.0/post-migration.py | 26 ++++ dms/models/access_groups.py | 4 + dms/static/description/index.html | 54 ++++----- 5 files changed, 117 insertions(+), 97 deletions(-) create mode 100644 dms/migrations/18.0.1.2.0/post-migration.py diff --git a/dms/README.rst b/dms/README.rst index 0bcff95ab..678d0c611 100644 --- a/dms/README.rst +++ b/dms/README.rst @@ -1,7 +1,3 @@ -.. image:: https://odoo-community.org/readme-banner-image - :target: https://odoo-community.org/get-involved?utm_source=readme - :alt: Odoo Community Association - ========================== Document Management System ========================== @@ -17,7 +13,7 @@ Document Management System .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status :alt: Beta -.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fdms-lightgray.png?logo=github @@ -72,9 +68,9 @@ To configure this module, you need to: 2. Create a new document storage. You can choose between three options on ``Save Type``: - - ``Database``: Store the files on the database as a field - - ``Attachment``: Store the files as attachments - - ``File``: Store the files on the file system + - ``Database``: Store the files on the database as a field + - ``Attachment``: Store the files as attachments + - ``File``: Store the files on the file system 2. Create an access group ------------------------- @@ -82,13 +78,13 @@ To configure this module, you need to: 1. Next, create an administrative access group. Go to *Configuration -> Access Groups*. - - Create a new group, name it appropriately, and turn on all three - permissions (Create, Write and Unlink. Read is implied and always - enabled). - - Add any other top-level administrative users to the group if needed - (your user should already be there). - - You can create other groups in here later for fine-grained access - control. + - Create a new group, name it appropriately, and turn on all three + permissions (Create, Write and Unlink. Read is implied and always + enabled). + - Add any other top-level administrative users to the group if + needed (your user should already be there). + - You can create other groups in here later for fine-grained access + control. 3. Create a directory --------------------- @@ -98,18 +94,18 @@ To configure this module, you need to: 2. Create a new directory, mark it as root and select the previously created setting. - - Select the *Groups* tab and add your administrative group created - above. If your directory was already created before the group, you - can also add it in the access groups (*Configuration -> Access - Groups*). + - Select the *Groups* tab and add your administrative group created + above. If your directory was already created before the group, you + can also add it in the access groups (*Configuration -> Access + Groups*). 3. In the directory settings, you can also add other access groups (created above) that will be able to: - - read - - create - - write - - delete + - read + - create + - write + - delete Migration ========= @@ -155,28 +151,28 @@ access to that resource, no matter if logged or not. Known issues / Roadmap ====================== -- Files preview in portal -- Allow to download folder in portal and create zip file with all - content -- Save in cache own_root directories and update in every - create/write/unlink function -- Add a migration procedure for converting an storage to attachment one - for populating existing records with attachments as folders -- Add a link from attachment view in chatter to linked documents -- If Inherit permissions from related record (the - inherit_access_from_parent_record field from storage) is changed when - directories already exist, inconsistencies may occur because groups - defined in the directories and subdirectories will still exist, all - groups in these directories should be removed before changing. -- Since portal users can read ``dms.storage`` records, if your module - extends this model to another storage backend that needs using - secrets, remember to forbid access to the secrets fields by other - means. It would be nice to be able to remove that rule at some point. -- Searchpanel in files: Highlight items (shading) without records when - filtering something (by name for example). -- Accessing the clipboard (for example copy share link of - file/directory) is limited to secure connections. It also happens in - any part of Odoo. +- Files preview in portal +- Allow to download folder in portal and create zip file with all + content +- Save in cache own_root directories and update in every + create/write/unlink function +- Add a migration procedure for converting an storage to attachment one + for populating existing records with attachments as folders +- Add a link from attachment view in chatter to linked documents +- If Inherit permissions from related record (the + inherit_access_from_parent_record field from storage) is changed when + directories already exist, inconsistencies may occur because groups + defined in the directories and subdirectories will still exist, all + groups in these directories should be removed before changing. +- Since portal users can read ``dms.storage`` records, if your module + extends this model to another storage backend that needs using + secrets, remember to forbid access to the secrets fields by other + means. It would be nice to be able to remove that rule at some point. +- Searchpanel in files: Highlight items (shading) without records when + filtering something (by name for example). +- Accessing the clipboard (for example copy share link of + file/directory) is limited to secure connections. It also happens in + any part of Odoo. Bug Tracker =========== @@ -200,40 +196,40 @@ Authors Contributors ------------ -- Mathias Markl -- Enric Tobella -- Antoni Romera -- Gelu Boros -- `Tecnativa `__: +- Mathias Markl +- Enric Tobella +- Antoni Romera +- Gelu Boros +- `Tecnativa `__: - - Víctor Martínez - - Pedro M. Baeza - - Jairo Llopis + - Víctor Martínez + - Pedro M. Baeza + - Jairo Llopis -- `Elego `__: +- `Elego `__: - - Yu Weng - - Philip Witte - - Khanh Bui + - Yu Weng + - Philip Witte + - Khanh Bui -- `Subteno `__: +- `Subteno `__: - - Timothée Vannier + - Timothée Vannier -- `Kencove `__: +- `Kencove `__: - - Mohamed Alkobrosli + - Mohamed Alkobrosli Other credits ------------- Some pictures are based on or inspired by: -- `Roundicons `__ -- `Smashicons `__ -- `EmojiOne `__ : Portal DMS icon -- `GitHub Octicons `__ : The main - DMS icon +- `Roundicons `__ +- `Smashicons `__ +- `EmojiOne `__ : Portal DMS icon +- `GitHub Octicons `__ : The main + DMS icon Maintainers ----------- diff --git a/dms/__manifest__.py b/dms/__manifest__.py index 33cb34290..420bf2a5c 100644 --- a/dms/__manifest__.py +++ b/dms/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Document Management System", "summary": """Document Management System for Odoo""", - "version": "18.0.1.1.4", + "version": "18.0.1.2.0", "category": "Document Management", "license": "LGPL-3", "website": "https://github.com/OCA/dms", diff --git a/dms/migrations/18.0.1.2.0/post-migration.py b/dms/migrations/18.0.1.2.0/post-migration.py new file mode 100644 index 000000000..54bd0ceff --- /dev/null +++ b/dms/migrations/18.0.1.2.0/post-migration.py @@ -0,0 +1,26 @@ +# Copyright 2026 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + """If there were archived users linked in `explicit_user_ids`, the relationship + did exist in the `dms_access_group_explicit_users_rel` table; therefore, those + users will now "appear" in `explicit_user_ids`, and it will be necessary to call + the `_compute_users()` method so that the `users` and `count_users` fields have + the correct values. + It is extremely important that the `users` field has the correct values; otherwise, + if we activate any of those users, they will not be able to view the linked records. + We set `active_test=False` in the search context to ensure that archived users are + taken into account, even though the `explicit_user_ids` field has that context + defined in the field itself. + """ + groups = ( + env["dms.access.group"] + .sudo() + .with_context(active_test=False) + .search([("explicit_user_ids.active", "=", False)]) + ) + if groups: + groups._compute_users() diff --git a/dms/models/access_groups.py b/dms/models/access_groups.py index 71113d28b..cc8830ca2 100644 --- a/dms/models/access_groups.py +++ b/dms/models/access_groups.py @@ -82,6 +82,7 @@ class DmsAccessGroups(models.Model): ) explicit_user_ids = fields.Many2many( comodel_name="res.users", + context={"active_test": False}, relation="dms_access_group_explicit_users_rel", column1="gid", column2="uid", @@ -89,6 +90,7 @@ class DmsAccessGroups(models.Model): ) users = fields.Many2many( comodel_name="res.users", + context={"active_test": False}, relation="dms_access_group_users_rel", column1="gid", column2="uid", @@ -142,8 +144,10 @@ def default_get(self, fields_list): @api.depends( "parent_group_id", "parent_group_id.users", + "parent_group_id.users.active", "group_ids", "group_ids.users", + "group_ids.users.active", "explicit_user_ids", ) def _compute_users(self): diff --git a/dms/static/description/index.html b/dms/static/description/index.html index eef9e1b55..c0db3985a 100644 --- a/dms/static/description/index.html +++ b/dms/static/description/index.html @@ -3,7 +3,7 @@ -README.rst +Document Management System -
+
+

Document Management System

- - -Odoo Community Association - -
-

Document Management System

-

Beta License: LGPL-3 OCA/dms Translate me on Weblate Try me on Runboat

+

Beta License: LGPL-3 OCA/dms Translate me on Weblate Try me on Runboat

DMS is a module for creating, managing and viewing document files directly within Odoo. This module is only the basis for an entire ecosystem of apps that extend and seamlessly integrate with the document @@ -415,21 +410,21 @@

Document Management System

-

Installation

+

Installation

-

Preview

+

Preview

python-magic library is recommended to be installed for having whole support to get proper file types and file preview.

-

Configuration

+

Configuration

To configure this module, you need to:

-

1. Create a storage

+

1. Create a storage

  1. Go to Documents -> Configuration -> Storages.
  2. Create a new document storage. You can choose between three options @@ -442,15 +437,15 @@

    1. Create a storage

-

2. Create an access group

+

2. Create an access group

  1. Next, create an administrative access group. Go to Configuration -> Access Groups.
    • Create a new group, name it appropriately, and turn on all three permissions (Create, Write and Unlink. Read is implied and always enabled).
    • -
    • Add any other top-level administrative users to the group if needed -(your user should already be there).
    • +
    • Add any other top-level administrative users to the group if +needed (your user should already be there).
    • You can create other groups in here later for fine-grained access control.
    @@ -458,7 +453,7 @@

    2. Create an access group

-

3. Create a directory

+

3. Create a directory

  1. Afterward, go to Documents -> Directories.
  2. Create a new directory, mark it as root and select the previously @@ -481,7 +476,7 @@

    3. Create a directory

-

Migration

+

Migration

If you need to modify the storage Save Type you might want to migrate the file data. To achieve it, you need to:

    @@ -497,19 +492,19 @@

    Migration

    Migration

-

File Wizard Selection

+

File Wizard Selection

There is an action called action_dms_file_wizard_selector to open a wizard to list files in kanban view. This can be used (example dms_attachment_link module) to add a button in kanban view with the action we need.

-

Usage

+

Usage

The best way to manage the documents is to switch to the Documents view. Existing documents can be managed there and new documents can be created.

-

Portal functionality

+

Portal functionality

You can add any portal user to DMS access groups, and then allow that group in directories, so they will see in the portal such directories and their files. Another possibility is to click on “Share” button @@ -518,7 +513,7 @@

Portal functionality

-

Known issues / Roadmap

+

Known issues / Roadmap

  • Files preview in portal
  • Allow to download folder in portal and create zip file with all @@ -545,7 +540,7 @@

    Known issues / Roadmap

-

Bug Tracker

+

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed @@ -553,16 +548,16 @@

Bug Tracker

Do not contact contributors directly about support or help with technical issues.

-

Credits

+

Credits

-

Authors

+

Authors

  • MuK IT
  • Tecnativa
-

Contributors

+

Contributors

-

Other credits

+

Other credits

Some pictures are based on or inspired by:

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association @@ -615,6 +610,5 @@

Maintainers

-
From c490ed0b4b3ac933eef7b658a345a7adde99cfd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Fri, 4 Sep 2026 10:26:15 +0200 Subject: [PATCH 2/2] [IMP] dms_user_role: Add role_ids.users.active to depends It is important that, if a user is activated, the _compute_users() method be called so that the "users" field contains the correct data. TT64366 --- dms_user_role/models/dms_access_group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dms_user_role/models/dms_access_group.py b/dms_user_role/models/dms_access_group.py index 9c0e2e757..07b19c926 100644 --- a/dms_user_role/models/dms_access_group.py +++ b/dms_user_role/models/dms_access_group.py @@ -15,7 +15,7 @@ class DmsAccessGroup(models.Model): string="Roles", ) - @api.depends("role_ids", "role_ids.users") + @api.depends("role_ids", "role_ids.users", "role_ids.users.active") def _compute_users(self): """Add the corresponding depends and the users of the roles.""" res = super()._compute_users()