Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions dms/README.rst
Original file line number Diff line number Diff line change
@@ -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
==========================
Expand All @@ -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
Expand Down Expand Up @@ -209,6 +205,7 @@ Contributors
- Víctor Martínez
- Pedro M. Baeza
- Jairo Llopis
- Adasat Torres

- `Elego <https://www.elegosoft.com>`__:

Expand Down
1 change: 1 addition & 0 deletions dms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import controllers
from . import models
from . import wizards
from .hooks import post_init_hook
1 change: 1 addition & 0 deletions dms/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@
],
"icon": "/dms/static/description/icon.png",
"application": True,
"post_init_hook": "post_init_hook",
}
168 changes: 168 additions & 0 deletions dms/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# Copyright 2026 Tecnativa - Adasat Torres
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import Command


def _create_default_storage(env, company):
return env["dms.storage"].create(
{
"name": f"EE storage - {company.name}",
"save_type": "file",
"company_id": company.id,
}
)


def _search_or_create(env, model, domain, vals):
Model = env[model]
res = Model.search(domain)
if not res:
res = Model.create(vals)
return res


def _prepare_dms_tags_vals(ee_tag, category_id):
return {"name": ee_tag.name, "category_id": category_id}


def _prepare_category_vals(ee_category):
return {"name": ee_category.name}


def _prepare_directory_vals(ee_folder, **kwargs):
return {"name": ee_folder.name, **kwargs}


def _prepare_file_vals(ee_document, directory_id, tag_ids):
return {
"name": ee_document.name,
"extension": ee_document.file_extension,
"content": ee_document.datas,
"directory_id": directory_id.id,
"tag_ids": [Command.set(tag_ids.ids if tag_ids else [])],
}


def _search_create_category(env, ee_facet):
return _search_or_create(
env,
"dms.category",
[("name", "ilike", ee_facet.name)],
_prepare_category_vals(ee_facet),
)


def _search_create_tag(env, ee_tags, category=False):
tags = env["dms.tag"]
for ee_tag in ee_tags:
tags += _search_or_create(
env,
"dms.tag",
[("name", "ilike", ee_tag.name)],
_prepare_dms_tags_vals(ee_tag, category.id if category else False),
)
return tags


def _create_categories_and_tags(env, ee_facets):
for ee_facet in ee_facets:
categ = _search_create_category(env, ee_facet)
_search_create_tag(env, ee_facet.tag_ids, categ)


def _search_create_directory(env, folder, **kwargs):
return _search_or_create(
env,
"dms.directory",
[("name", "=", folder.name)],
_prepare_directory_vals(folder, **kwargs),
)


def _search_create_admin_dms_access_group(env):
return _search_create_dms_access_group(
env,
**{
"name": "Admin",
"group_ids": [Command.link(env.ref("base.group_system").id)],
"perm_create": True,
"perm_write": True,
"perm_unlink": True,
},
)


def _search_create_dms_access_group(env, **kwargs):
return _search_or_create(
env, "dms.access.group", [("name", "ilike", kwargs.get("name", False))], kwargs
)


def _create_file(env, ee_document, directory):
tags = _search_create_tag(env, ee_document.tag_ids)
_search_or_create(
env,
"dms.file",
[("name", "=", ee_document.name), ("directory_id", "=", directory.id)],
_prepare_file_vals(ee_document, directory, tags),
)


def _create_directory_and_files(env, ee_folder, storage):
admin_access_group = _search_create_admin_dms_access_group(env)
vals = {
"is_root_directory": True,
"storage_id": storage.id,
"group_ids": [Command.link(admin_access_group.id)],
}
if ee_folder.read_group_ids:
read_access_group = _search_create_dms_access_group(
env,
**{
"name": f"{ee_folder.name} - Read",
"group_ids": [Command.set(ee_folder.read_group_ids.ids)],
"perm_create": False,
"perm_write": False,
"perm_unlink": False,
},
)
vals["group_ids"].append(Command.link(read_access_group.id))
if ee_folder.group_ids:
write_access_group = _search_create_dms_access_group(
env,
**{
"name": f"{ee_folder.name} - Write",
"group_ids": [Command.set(ee_folder.group_ids.ids)],
"perm_create": True,
"perm_write": True,
"perm_unlink": False,
},
)
vals["group_ids"].append(Command.link(write_access_group.id))
if ee_folder.parent_folder_id:
vals["parent_id"] = _search_create_directory(
env, ee_folder.parent_folder_id, **vals
).id
vals["is_root_directory"] = False
vals.pop("storage_id")
if ee_folder.facet_ids:
vals["category_id"] = _search_create_category(env, ee_folder.facet_ids[0]).id
directory = _search_create_directory(env, ee_folder, **vals)
for document in ee_folder.document_ids.filtered(lambda d: d.type == "binary"):
_create_file(env, document, directory)


def post_init_hook(env):
if not env["ir.module.module"].search(
[("name", "=", "documents"), ("state", "=", "installed")]
):
return
DocumentsFolder = env["documents.folder"]
for company in env["res.company"].search([]):
if not DocumentsFolder.search([], limit=1):
continue
storage = _create_default_storage(env, company)
for folder in DocumentsFolder.search([]):
_create_categories_and_tags(env, folder.mapped("facet_ids"))
_create_directory_and_files(env, folder, storage)
1 change: 1 addition & 0 deletions dms/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Víctor Martínez
- Pedro M. Baeza
- Jairo Llopis
- Adasat Torres
- [Elego](https://www.elegosoft.com):
- Yu Weng \<<yweng@elegosoft.com>\>
- Philip Witte \<<phillip.witte@elegosoft.com>\>
Expand Down
51 changes: 23 additions & 28 deletions dms/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Document Management System</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="document-management-system">
<h1 class="title">Document Management System</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="document-management-system">
<h1>Document Management System</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:34268a54fbea2d3f8d70897c260a49f4873c2b3bf860ffe4d57b44022cb686d5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/dms/tree/17.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-17-0/dms-17-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=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<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/17.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-17-0/dms-17-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=17.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 within Odoo. This module is only the basis for an entire
ecosystem of apps that extend and seamlessly integrate with the document
Expand Down Expand Up @@ -415,21 +410,21 @@ <h1>Document Management System</h1>
</ul>
</div>
<div class="section" id="installation">
<h2><a class="toc-backref" href="#toc-entry-1">Installation</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Installation</a></h1>
<div class="section" id="preview">
<h3><a class="toc-backref" href="#toc-entry-2">Preview</a></h3>
<h2><a class="toc-backref" href="#toc-entry-2">Preview</a></h2>
<p><tt class="docutils literal"><span class="pre">python-magic</span></tt> library is recommended to be installed for having whole
support to get proper file types and file preview.</p>
</div>
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#toc-entry-3">Configuration</a></h2>
<h1><a class="toc-backref" href="#toc-entry-3">Configuration</a></h1>
</div>
<div class="section" id="configuration-1">
<h2><a class="toc-backref" href="#toc-entry-4">Configuration</a></h2>
<h1><a class="toc-backref" href="#toc-entry-4">Configuration</a></h1>
<p>To configure this module, you need to:</p>
<div class="section" id="create-a-storage">
<h3><a class="toc-backref" href="#toc-entry-5">1. Create a storage</a></h3>
<h2><a class="toc-backref" href="#toc-entry-5">1. Create a storage</a></h2>
<ol class="arabic simple">
<li>Go to <em>Documents -&gt; Configuration -&gt; Storages</em>.</li>
<li>Create a new document storage. You can choose between three options
Expand All @@ -442,7 +437,7 @@ <h3><a class="toc-backref" href="#toc-entry-5">1. Create a storage</a></h3>
</ol>
</div>
<div class="section" id="create-an-access-group">
<h3><a class="toc-backref" href="#toc-entry-6">2. Create an access group</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">2. Create an access group</a></h2>
<ol class="arabic simple">
<li>Next, create an administrative access group. Go to <em>Configuration -&gt;
Access Groups</em>.<ul>
Expand All @@ -458,7 +453,7 @@ <h3><a class="toc-backref" href="#toc-entry-6">2. Create an access group</a></h3
</ol>
</div>
<div class="section" id="create-a-directory">
<h3><a class="toc-backref" href="#toc-entry-7">3. Create a directory</a></h3>
<h2><a class="toc-backref" href="#toc-entry-7">3. Create a directory</a></h2>
<ol class="arabic simple">
<li>Afterward, go to <em>Documents -&gt; Directories</em>.</li>
<li>Create a new directory, mark it as root and select the previously
Expand All @@ -481,7 +476,7 @@ <h3><a class="toc-backref" href="#toc-entry-7">3. Create a directory</a></h3>
</div>
</div>
<div class="section" id="migration">
<h2><a class="toc-backref" href="#toc-entry-8">Migration</a></h2>
<h1><a class="toc-backref" href="#toc-entry-8">Migration</a></h1>
<p>If you need to modify the storage <tt class="docutils literal">Save Type</tt> you might want to
migrate the file data. To achieve it, you need to:</p>
<ol class="arabic simple">
Expand All @@ -497,19 +492,19 @@ <h2><a class="toc-backref" href="#toc-entry-8">Migration</a></h2>
Migration</em></p>
</div>
<div class="section" id="file-wizard-selection">
<h2><a class="toc-backref" href="#toc-entry-9">File Wizard Selection</a></h2>
<h1><a class="toc-backref" href="#toc-entry-9">File Wizard Selection</a></h1>
<p>There is an action called <tt class="docutils literal">action_dms_file_wizard_selector</tt> 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.</p>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-10">Usage</a></h2>
<h1><a class="toc-backref" href="#toc-entry-10">Usage</a></h1>
<p>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.</p>
<div class="section" id="portal-functionality">
<h3><a class="toc-backref" href="#toc-entry-11">Portal functionality</a></h3>
<h2><a class="toc-backref" href="#toc-entry-11">Portal functionality</a></h2>
<p>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
Expand All @@ -518,7 +513,7 @@ <h3><a class="toc-backref" href="#toc-entry-11">Portal functionality</a></h3>
</div>
</div>
<div class="section" id="known-issues-roadmap">
<h2><a class="toc-backref" href="#toc-entry-12">Known issues / Roadmap</a></h2>
<h1><a class="toc-backref" href="#toc-entry-12">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>Files preview in portal</li>
<li>Allow to download folder in portal and create zip file with all
Expand All @@ -545,24 +540,24 @@ <h2><a class="toc-backref" href="#toc-entry-12">Known issues / Roadmap</a></h2>
</ul>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-13">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-13">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/dms/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/dms/issues/new?body=module:%20dms%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-14">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-14">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-15">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-15">Authors</a></h2>
<ul class="simple">
<li>MuK IT</li>
<li>Tecnativa</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-16">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-16">Contributors</a></h2>
<ul class="simple">
<li>Mathias Markl &lt;<a class="reference external" href="mailto:mathias.markl&#64;mukit.at">mathias.markl&#64;mukit.at</a>&gt;</li>
<li>Enric Tobella &lt;<a class="reference external" href="mailto:etobella&#64;creublanca.es">etobella&#64;creublanca.es</a>&gt;</li>
Expand All @@ -572,6 +567,7 @@ <h3><a class="toc-backref" href="#toc-entry-16">Contributors</a></h3>
<li>Víctor Martínez</li>
<li>Pedro M. Baeza</li>
<li>Jairo Llopis</li>
<li>Adasat Torres</li>
</ul>
</li>
<li><a class="reference external" href="https://www.elegosoft.com">Elego</a>:<ul>
Expand All @@ -587,7 +583,7 @@ <h3><a class="toc-backref" href="#toc-entry-16">Contributors</a></h3>
</ul>
</div>
<div class="section" id="other-credits">
<h3><a class="toc-backref" href="#toc-entry-17">Other credits</a></h3>
<h2><a class="toc-backref" href="#toc-entry-17">Other credits</a></h2>
<p>Some pictures are based on or inspired by:</p>
<ul class="simple">
<li><a class="reference external" href="https://www.flaticon.com/authors/roundicons">Roundicons</a></li>
Expand All @@ -598,7 +594,7 @@ <h3><a class="toc-backref" href="#toc-entry-17">Other credits</a></h3>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-18">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-18">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -611,6 +607,5 @@ <h3><a class="toc-backref" href="#toc-entry-18">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
Loading