Repository: paperless-ngx/paperless-ngx

Issue:
[BUG ]At new splitting: "QuerySet' object has no attribute 'extend'" - Workflow adding a custom field on adding new document leads to the error message
### Description

When trying out the new splitting functionality I get the error message: 

  'QuerySet' object has no attribute 'extend'

A Workflow for adding a custom field on adding new document leads to the error message.

Anybody with the same issue?


### Steps to reproduce

1. Go to Documents
2. Edit Document
3. Split
4. Split Pages 1 and 2
5. Error message

### Webserver logs

```bash
[2024-04-06 11:18:26,873] [DEBUG] [paperless.tasks] Executing plugin WorkflowTriggerPlugin

[2024-04-06 11:18:26,905] [INFO] [paperless.matching] Document matched WorkflowTrigger 3 from Workflow: Benutzerdefinierte Felder hinzufügen

[2024-04-06 11:18:26,910] [ERROR] [paperless.tasks] WorkflowTriggerPlugin failed: 'QuerySet' object has no attribute 'extend'

Traceback (most recent call last):

  File "/usr/src/paperless/src/documents/tasks.py", line 144, in consume_file

    msg = plugin.run()

          ^^^^^^^^^^^^

  File "/usr/src/paperless/src/documents/consumer.py", line 223, in run

    self.metadata.update(overrides)

  File "/usr/src/paperless/src/documents/data_models.py", line 64, in update

    self.view_users.extend(other.view_users)

    ^^^^^^^^^^^^^^^^^^^^^^

AttributeError: 'QuerySet' object has no attribute 'extend'
```


### Browser logs

_No response_

### Paperless-ngx version

2.7.0

### Host OS

Docker on Synology NAS - DSM 7.2

### Installation method

Docker - official image

### Browser

Firefox

### Configuration changes

_No response_

### Other

_No response_

### Please confirm the following

- [X] I believe this issue is a bug that affects all users of Paperless-ngx, not something specific to my installation.
- [X] I have already searched for relevant existing issues and discussions before opening this report.
- [X] I have updated the title field above with a concise description.


Discussion:

Resolving patch:
diff --git a/src/documents/data_models.py b/src/documents/data_models.py
--- a/src/documents/data_models.py
+++ b/src/documents/data_models.py
@@ -103,14 +103,18 @@ def from_document(doc) -> "DocumentMetadataOverrides":
         overrides.owner_id = doc.owner.id if doc.owner else None
         overrides.tag_ids = list(doc.tags.values_list("id", flat=True))
 
-        overrides.view_users = get_users_with_perms(
-            doc,
-            only_with_perms_in=["view_document"],
-        ).values_list("id", flat=True)
-        overrides.change_users = get_users_with_perms(
-            doc,
-            only_with_perms_in=["change_document"],
-        ).values_list("id", flat=True)
+        overrides.view_users = list(
+            get_users_with_perms(
+                doc,
+                only_with_perms_in=["view_document"],
+            ).values_list("id", flat=True),
+        )
+        overrides.change_users = list(
+            get_users_with_perms(
+                doc,
+                only_with_perms_in=["change_document"],
+            ).values_list("id", flat=True),
+        )
         overrides.custom_field_ids = list(
             doc.custom_fields.values_list("id", flat=True),
         )
@@ -120,10 +124,14 @@ def from_document(doc) -> "DocumentMetadataOverrides":
             attach_perms=True,
         )
         overrides.view_groups = [
-            group.id for group, perms in groups_with_perms if "view_document" in perms
+            group.id
+            for group in groups_with_perms
+            if "view_document" in groups_with_perms[group]
         ]
         overrides.change_groups = [
-            group.id for group, perms in groups_with_perms if "change_document" in perms
+            group.id
+            for group in groups_with_perms
+            if "change_document" in groups_with_perms[group]
         ]
 
         return overrides


Test patch: