diff --git a/attachment_category/README.rst b/attachment_category/README.rst new file mode 100644 index 00000000000..aa3feddc1df --- /dev/null +++ b/attachment_category/README.rst @@ -0,0 +1,81 @@ +================== +Atachment Category +================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:06d5f4bb34bd79a7d4b19e08c7ce71550f12bce30e22eeccc7989b3e2045bfda + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github + :target: https://github.com/OCA/knowledge/tree/17.0/attachment_category + :alt: OCA/knowledge +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/knowledge-17-0/knowledge-17-0-attachment_category + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/knowledge&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a document category to help classification. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +- Go to Attachments, and set categories as tags. + +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 +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* ACSONE SA/NV + +Contributors +------------ + +- Denis Roussel + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/knowledge `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/attachment_category/__init__.py b/attachment_category/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/attachment_category/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/attachment_category/__manifest__.py b/attachment_category/__manifest__.py new file mode 100644 index 00000000000..456b3b6474b --- /dev/null +++ b/attachment_category/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Atachment Category", + "summary": """ + Adds a document category to help classification""", + "version": "17.0.1.0.1", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "depends": ["base"], + "website": "https://github.com/OCA/knowledge", + "data": [ + "views/ir_attachment.xml", + "security/ir_attachment_category.xml", + "views/ir_attachment_category.xml", + ], +} diff --git a/attachment_category/i18n/attachment_category.pot b/attachment_category/i18n/attachment_category.pot new file mode 100644 index 00000000000..75a10b5f323 --- /dev/null +++ b/attachment_category/i18n/attachment_category.pot @@ -0,0 +1,104 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * attachment_category +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: attachment_category +#: model_terms:ir.actions.act_window,help:attachment_category.ir_attachment_category_act_window +msgid "Also you will find here all the related document categories." +msgstr "" + +#. module: attachment_category +#: model:ir.model,name:attachment_category.model_ir_attachment +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__attachment_ids +msgid "Attachment" +msgstr "" + +#. module: attachment_category +#: model:ir.actions.act_window,name:attachment_category.ir_attachment_category_act_window +#: model:ir.ui.menu,name:attachment_category.ir_attachment_category_menu +msgid "Attachment Categories" +msgstr "" + +#. module: attachment_category +#: model:ir.model,name:attachment_category.model_ir_attachment_category +msgid "Attachment Category" +msgstr "" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__attachment_count +msgid "Attachment Count" +msgstr "" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment__category_ids +msgid "Category" +msgstr "" + +#. module: attachment_category +#: model_terms:ir.actions.act_window,help:attachment_category.ir_attachment_category_act_window +msgid "Create a new document" +msgstr "" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__create_uid +msgid "Created by" +msgstr "" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__create_date +msgid "Created on" +msgstr "" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment__display_name +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__display_name +msgid "Display Name" +msgstr "" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment__id +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__id +msgid "ID" +msgstr "" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment____last_update +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category____last_update +msgid "Last Modified on" +msgstr "" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__write_date +msgid "Last Updated on" +msgstr "" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__name +msgid "Name" +msgstr "" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__parent_id +msgid "Parent" +msgstr "" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__parent_path +msgid "Parent Path" +msgstr "" diff --git a/attachment_category/i18n/es.po b/attachment_category/i18n/es.po new file mode 100644 index 00000000000..551b82ed795 --- /dev/null +++ b/attachment_category/i18n/es.po @@ -0,0 +1,108 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * attachment_category +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-02-18 23:56+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: attachment_category +#: model_terms:ir.actions.act_window,help:attachment_category.ir_attachment_category_act_window +msgid "Also you will find here all the related document categories." +msgstr "" +"También encontrará aquí todas las categorías de documentos relacionados." + +#. module: attachment_category +#: model:ir.model,name:attachment_category.model_ir_attachment +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__attachment_ids +msgid "Attachment" +msgstr "Archivo adjunto" + +#. module: attachment_category +#: model:ir.actions.act_window,name:attachment_category.ir_attachment_category_act_window +#: model:ir.ui.menu,name:attachment_category.ir_attachment_category_menu +msgid "Attachment Categories" +msgstr "Categorías de Archivos Adjuntos" + +#. module: attachment_category +#: model:ir.model,name:attachment_category.model_ir_attachment_category +msgid "Attachment Category" +msgstr "Categoría de Archivos Adjuntos" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__attachment_count +msgid "Attachment Count" +msgstr "Conteo de Anexos" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment__category_ids +msgid "Category" +msgstr "Categoría" + +#. module: attachment_category +#: model_terms:ir.actions.act_window,help:attachment_category.ir_attachment_category_act_window +msgid "Create a new document" +msgstr "Crear un nuevo documento" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__create_date +msgid "Created on" +msgstr "Creado el" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment__display_name +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__display_name +msgid "Display Name" +msgstr "Mostrar Nombre" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment__id +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__id +msgid "ID" +msgstr "ID (identificación)" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment____last_update +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category____last_update +msgid "Last Modified on" +msgstr "Última Modificación el" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__write_uid +msgid "Last Updated by" +msgstr "Última Actualización por" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__write_date +msgid "Last Updated on" +msgstr "Última Actualización el" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__name +msgid "Name" +msgstr "Nombre" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__parent_id +msgid "Parent" +msgstr "Parental" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__parent_path +msgid "Parent Path" +msgstr "Ruta Parental" diff --git a/attachment_category/i18n/it.po b/attachment_category/i18n/it.po new file mode 100644 index 00000000000..e3fae330927 --- /dev/null +++ b/attachment_category/i18n/it.po @@ -0,0 +1,107 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * attachment_category +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-01-03 12:46+0000\n" +"Last-Translator: Francesco Foresti \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.14.1\n" + +#. module: attachment_category +#: model_terms:ir.actions.act_window,help:attachment_category.ir_attachment_category_act_window +msgid "Also you will find here all the related document categories." +msgstr "Inoltre qui si troveranno tutte le categorie documenti collegate." + +#. module: attachment_category +#: model:ir.model,name:attachment_category.model_ir_attachment +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__attachment_ids +msgid "Attachment" +msgstr "Allegato" + +#. module: attachment_category +#: model:ir.actions.act_window,name:attachment_category.ir_attachment_category_act_window +#: model:ir.ui.menu,name:attachment_category.ir_attachment_category_menu +msgid "Attachment Categories" +msgstr "Categorie allegato" + +#. module: attachment_category +#: model:ir.model,name:attachment_category.model_ir_attachment_category +msgid "Attachment Category" +msgstr "Categoria allegato" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__attachment_count +msgid "Attachment Count" +msgstr "Numero allegati" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment__category_ids +msgid "Category" +msgstr "Categoria" + +#. module: attachment_category +#: model_terms:ir.actions.act_window,help:attachment_category.ir_attachment_category_act_window +msgid "Create a new document" +msgstr "Crea un nuovo documento" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__create_uid +msgid "Created by" +msgstr "Creato da" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__create_date +msgid "Created on" +msgstr "Creato il" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment__display_name +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment__id +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__id +msgid "ID" +msgstr "ID" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment____last_update +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__write_uid +msgid "Last Updated by" +msgstr "Ultimo aggiornamento di" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__write_date +msgid "Last Updated on" +msgstr "Ultimo aggiornamento il" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__name +msgid "Name" +msgstr "Nome" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__parent_id +msgid "Parent" +msgstr "Padre" + +#. module: attachment_category +#: model:ir.model.fields,field_description:attachment_category.field_ir_attachment_category__parent_path +msgid "Parent Path" +msgstr "Percorso padre" diff --git a/attachment_category/models/__init__.py b/attachment_category/models/__init__.py new file mode 100644 index 00000000000..6858a37c7f8 --- /dev/null +++ b/attachment_category/models/__init__.py @@ -0,0 +1,2 @@ +from . import ir_attachment_category +from . import ir_attachment diff --git a/attachment_category/models/ir_attachment.py b/attachment_category/models/ir_attachment.py new file mode 100644 index 00000000000..111f1b18e55 --- /dev/null +++ b/attachment_category/models/ir_attachment.py @@ -0,0 +1,17 @@ +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class IrAttachment(models.Model): + _inherit = "ir.attachment" + + category_ids = fields.Many2many( + comodel_name="ir.attachment.category", + relation="ir_attachment_category_rel", + column1="attachment_id", + column2="category_id", + ondelete="restrict", + index=True, + ) diff --git a/attachment_category/models/ir_attachment_category.py b/attachment_category/models/ir_attachment_category.py new file mode 100644 index 00000000000..bc03b88dbb0 --- /dev/null +++ b/attachment_category/models/ir_attachment_category.py @@ -0,0 +1,69 @@ +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class IrAttachmentCategory(models.Model): + _name = "ir.attachment.category" + _description = "Attachment Category" + _parent_store = True + + name = fields.Char() + display_name = fields.Char( + compute="_compute_display_name", + store=True, + recursive=True, + ) + parent_id = fields.Many2one( + "ir.attachment.category", + ) + parent_path = fields.Char( + index=True, + unaccent=False, + ) + attachment_ids = fields.Many2many( + compute="_compute_attachment_count", comodel_name="ir.attachment" + ) + attachment_count = fields.Integer( + compute="_compute_attachment_count", + ) + + @api.depends("name", "parent_id.display_name") + def _compute_display_name(self): + """ + + :return: + """ + for category in self: + if category.parent_id.display_name: + category.display_name = "{}/{}".format( + category.parent_id.display_name, + category.name, + ) + else: + category.display_name = category.name + + def _compute_attachment_count(self): + category_obj = self.env["ir.attachment.category"] + attachment_obj = self.env["ir.attachment"] + for category in self: + if isinstance(category.id, models.NewId): + category.attachment_count = 0 + category.attachment_ids = attachment_obj.browse() + continue + child_categories = category_obj.search([("id", "child_of", category.id)]) + attachment_ids = attachment_obj.search( + [("category_ids", "in", child_categories.ids)] + ) + category.attachment_ids = attachment_ids + category.attachment_count = len(attachment_ids) + + def action_attachment_view(self): + self.ensure_one() + action = self.env["ir.actions.act_window"]._for_xml_id("base.action_attachment") + action["domain"] = [("category_ids", "child_of", self.id)] + context = self.env.context.copy() + context.update({"default_category_ids": [self.id]}) + action["context"] = context + return action diff --git a/attachment_category/pyproject.toml b/attachment_category/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/attachment_category/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/attachment_category/readme/CONTRIBUTORS.md b/attachment_category/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..89c79f8e430 --- /dev/null +++ b/attachment_category/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Denis Roussel \<\> diff --git a/attachment_category/readme/DESCRIPTION.md b/attachment_category/readme/DESCRIPTION.md new file mode 100644 index 00000000000..60554088563 --- /dev/null +++ b/attachment_category/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module adds a document category to help classification. diff --git a/attachment_category/readme/USAGE.md b/attachment_category/readme/USAGE.md new file mode 100644 index 00000000000..08c33793128 --- /dev/null +++ b/attachment_category/readme/USAGE.md @@ -0,0 +1 @@ +- Go to Attachments, and set categories as tags. diff --git a/attachment_category/security/ir_attachment_category.xml b/attachment_category/security/ir_attachment_category.xml new file mode 100644 index 00000000000..354d0f546c9 --- /dev/null +++ b/attachment_category/security/ir_attachment_category.xml @@ -0,0 +1,14 @@ + + + + + Attachment Category User + + + + + + + + diff --git a/attachment_category/static/description/icon.png b/attachment_category/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/attachment_category/static/description/icon.png differ diff --git a/attachment_category/static/description/index.html b/attachment_category/static/description/index.html new file mode 100644 index 00000000000..e934d17418f --- /dev/null +++ b/attachment_category/static/description/index.html @@ -0,0 +1,427 @@ + + + + + +Atachment Category + + + +
+

Atachment Category

+ + +

Beta License: AGPL-3 OCA/knowledge Translate me on Weblate Try me on Runboat

+

This module adds a document category to help classification.

+

Table of contents

+ +
+

Usage

+
    +
  • Go to Attachments, and set categories as tags.
  • +
+
+
+

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 +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE SA/NV
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/knowledge project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/attachment_category/views/ir_attachment.xml b/attachment_category/views/ir_attachment.xml new file mode 100644 index 00000000000..c61f047a562 --- /dev/null +++ b/attachment_category/views/ir_attachment.xml @@ -0,0 +1,35 @@ + + + + + ir.attachment.form (in attachment_category) + ir.attachment + + + + + + + + + ir.attachment.search (in attachment_category) + ir.attachment + + + + + + + + + ir.attachment.tree (in attachment_category) + ir.attachment + + + + + + + + diff --git a/attachment_category/views/ir_attachment_category.xml b/attachment_category/views/ir_attachment_category.xml new file mode 100644 index 00000000000..51c358d0772 --- /dev/null +++ b/attachment_category/views/ir_attachment_category.xml @@ -0,0 +1,65 @@ + + + + + ir.attachment.category.form (in document_category) + ir.attachment.category + +
+
+ +
+ +
+ +
+ + + + +
+
+
+
+ + ir.attachment.category.search (in document_category) + ir.attachment.category + + + + + + + + ir.attachment.category.tree (in document_category) + ir.attachment.category + + + + + + + + Attachment Categories + ir.attachment.category + tree,form + +

Create a new document

+

Also you will find here all the related document categories.

+
+
+ + Attachment Categories + + + + +