Skip to content

Commit

Permalink
[FIX] dms: Set the correct parent_id of directories in searchpanel
Browse files Browse the repository at this point in the history
If the parent directory is not in all the records we should not set
parent_id because the user does not have access to parent.

TT46388
  • Loading branch information
victoralmau committed Dec 14, 2023
1 parent 639272a commit 0653551
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dms/models/dms_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ def search_panel_select_range(self, field_name, **kwargs):
.with_context(directory_short_name=True)
.search_read(domain, ["display_name", "parent_id"])
)
all_record_ids = [rec["id"] for rec in comodel_records]
field_range = {}
enable_counters = kwargs.get("enable_counters")
for record in comodel_records:
Expand All @@ -313,7 +314,11 @@ def search_panel_select_range(self, field_name, **kwargs):
record_values = {
"id": record_id,
"display_name": record["display_name"],
"parent_id": parent[0] if parent else False,
# If the parent directory is not in all the records we should not
# set parent_id because the user does not have access to parent.
"parent_id": (
parent[0] if parent and parent[0] in all_record_ids else False
),
}
if enable_counters:
record_values["__count"] = 0
Expand Down

0 comments on commit 0653551

Please sign in to comment.