Skip to content

Commit

Permalink
Merge PR #280 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Jan 5, 2024
2 parents 7d22ca9 + 56bd76d commit f517fd7
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 24 deletions.
3 changes: 2 additions & 1 deletion dms/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Document Management System
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b8ef72f97bc86372d994edca1627ed8a58d0b72214d299bc7c49b9153b976f91
!! source digest: sha256:721474c85ecd534268e8049b628b0a111c99350057b875454a33b1bda305d3e8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -119,6 +119,7 @@ Known issues / Roadmap
- 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).

Bug Tracker
===========
Expand Down
41 changes: 30 additions & 11 deletions dms/models/dms_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,22 +295,41 @@ def _search_panel_domain(self, field, operator, directory_id, comodel_domain=Fal

@api.model
def search_panel_select_range(self, field_name, **kwargs):
operator, directory_id = self._search_panel_directory(**kwargs)
if directory_id and field_name == "directory_id":
domain = [("parent_id", operator, directory_id)]
values = (
"""This method is overwritten to make it 'similar' to v13.
The goal is that the directory searchpanel shows all directories
(even if some folders have no files)."""
if field_name == "directory_id":
domain = [["is_hidden", "=", False]]
comodel_records = (
self.env["dms.directory"]
.with_context(directory_short_name=True)
.search_read(domain, ["display_name", "parent_id"])
)
return {
"parent_field": "parent_id",
"values": values if len(values) > 1 else [],
}
all_record_ids = [rec["id"] for rec in comodel_records]
field_range = {}
enable_counters = kwargs.get("enable_counters")
for record in comodel_records:
record_id = record["id"]
parent = record["parent_id"]
record_values = {
"id": record_id,
"display_name": record["display_name"],
# 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
field_range[record_id] = record_values
if enable_counters:
res = super().search_panel_select_range(field_name, **kwargs)
for item in res["values"]:
field_range[item["id"]]["__count"] = item["__count"]
return {"parent_field": "parent_id", "values": list(field_range.values())}
context = {}
if field_name == "directory_id":
context["directory_short_name"] = True
elif field_name == "category_id":
if field_name == "category_id":
context["category_short_name"] = True
return super(File, self.with_context(**context)).search_panel_select_range(
field_name, **kwargs
Expand Down
1 change: 1 addition & 0 deletions dms/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
- 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).
3 changes: 2 additions & 1 deletion dms/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Document Management System</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b8ef72f97bc86372d994edca1627ed8a58d0b72214d299bc7c49b9153b976f91
!! source digest: sha256:721474c85ecd534268e8049b628b0a111c99350057b875454a33b1bda305d3e8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/dms/tree/16.0/dms"><img alt="OCA/dms" src="https://img.shields.io/badge/github-OCA%2Fdms-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/dms-16-0/dms-16-0-dms"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/dms&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>DMS is a module for creating, managing and viewing document files directly
Expand Down Expand Up @@ -497,6 +497,7 @@ <h1><a class="toc-backref" href="#toc-entry-8">Known issues / Roadmap</a></h1>
<li>Add a link from attachment view in chatter to linked documents</li>
<li>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.</li>
<li>Since portal users can read <tt class="docutils literal">dms.storage</tt> 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.</li>
<li>Searchpanel in files: Highlight items (shading) without records when filtering something (by name for example).</li>
</ul>
</div>
<div class="section" id="bug-tracker">
Expand Down
14 changes: 6 additions & 8 deletions dms/static/src/js/views/search_panel.esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @odoo-module **/
/* Copyright 2021-2022 Tecnativa - Víctor Martínez
/* Copyright 2021-2024 Tecnativa - Víctor Martínez
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */

import {SearchModel} from "@web/search/search_model";
Expand All @@ -17,13 +17,11 @@ patch(SearchModel.prototype, "dms.SearchPanel", {
continue;
}

if (this.resModel === "dms.directory") {
if (category.activeValueId) {
domain.push([category.fieldName, "=", category.activeValueId]);
}
if (domain.length === 0) {
domain.push([category.fieldName, "=", false]);
}
if (category.activeValueId) {
domain.push([category.fieldName, "=", category.activeValueId]);
}
if (domain.length === 0 && this.resModel === "dms.directory") {
domain.push([category.fieldName, "=", false]);
}
}
return domain;
Expand Down
2 changes: 2 additions & 0 deletions dms/tests/test_file_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,5 @@ def test_search_panel(self):
self.assertTrue(self.file.search_panel_select_range("directory_id"))
self.assertTrue(self.file.search_panel_select_multi_range("directory_id"))
self.assertTrue(self.file.search_panel_select_multi_range("tag_ids"))
res = self.file.search_panel_select_range("directory_id", enable_counters=True)
self.assertTrue(self.directory2.id == x["id"] for x in res["values"])
1 change: 0 additions & 1 deletion dms/views/directory.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@
icon="fa-folder"
limit="0"
enable_counters="1"
operator="="
/>
<field
name="category_id"
Expand Down
2 changes: 0 additions & 2 deletions dms/views/dms_file.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
name="directory_id"
icon="fa-folder"
limit="0"
operator="="
enable_counters="1"
/>
<field
Expand Down Expand Up @@ -573,7 +572,6 @@
icon="fa-folder"
limit="0"
enable_counters="1"
operator="="
/>
<field
name="category_id"
Expand Down

0 comments on commit f517fd7

Please sign in to comment.