diff --git a/hr_dms_field/README.rst b/hr_dms_field/README.rst new file mode 100644 index 000000000..b05ee2825 --- /dev/null +++ b/hr_dms_field/README.rst @@ -0,0 +1,107 @@ +=========================== +Add dms field for employees +=========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:99c1af9016e8a5e75bd43f6403d63230fbb9cfea89cb2e5e7e5885ec751a9db0 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fdms-lightgray.png?logo=github + :target: https://github.com/OCA/dms/tree/18.0/hr_dms_field + :alt: OCA/dms +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/dms-18-0/dms-18-0-hr_dms_field + :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/dms&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Add the Documents tab with the files in the employee's form view. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +1. *Go to Documents > Configuration > File templates* and create a new + record. +2. Set a storage, a model (hr.employee) and the access groups you want. +3. Click on the "Documents" tab icon and a folder hierarchy will be + created. +4. You can set here the hierarchy of directories, subdirectories and + files you need, this hierarchy will be used as a base when creating a + new record (res.partner for example). + +Usage +===== + +#. Go to the form view of an existing employee and click on the +"Documents" tab icon, a hierarchy of folders and files linked to that +record will be created. #. Create a new employee. A hierarchy of folders +and files linked to that record will be created. + +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 +------- + +* Tecnativa + +Contributors +------------ + +- `Tecnativa `__: + + - Víctor Martínez + - Pedro M. Baeza + +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. + +.. |maintainer-victoralmau| image:: https://github.com/victoralmau.png?size=40px + :target: https://github.com/victoralmau + :alt: victoralmau + +Current `maintainer `__: + +|maintainer-victoralmau| + +This module is part of the `OCA/dms `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/hr_dms_field/__init__.py b/hr_dms_field/__init__.py new file mode 100644 index 000000000..4b76c7b2d --- /dev/null +++ b/hr_dms_field/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/hr_dms_field/__manifest__.py b/hr_dms_field/__manifest__.py new file mode 100644 index 000000000..19decd6de --- /dev/null +++ b/hr_dms_field/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2024 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Add dms field for employees", + "version": "19.0.1.0.0", + "category": "Human Resources", + "website": "https://github.com/OCA/dms", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": ["hr", "dms_field"], + "installable": True, + "data": [ + "security/security.xml", + "views/hr_employee_view.xml", + "views/res_config_settings_view.xml", + ], + "demo": ["demo/dms_data.xml"], + "assets": { + "web.assets_backend": [ + "hr_dms_field/static/src/js/**/*", + ], + }, + "maintainers": ["victoralmau"], +} diff --git a/hr_dms_field/demo/dms_data.xml b/hr_dms_field/demo/dms_data.xml new file mode 100644 index 000000000..1a1be244b --- /dev/null +++ b/hr_dms_field/demo/dms_data.xml @@ -0,0 +1,21 @@ + + + + Everyone for Employee DMS + + + + + + + Employee + + + + + + {{object.display_name}} (employee) + + diff --git a/hr_dms_field/i18n/ar.po b/hr_dms_field/i18n/ar.po new file mode 100644 index 000000000..b708cb794 --- /dev/null +++ b/hr_dms_field/i18n/ar.po @@ -0,0 +1,67 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_dms_field +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: ar\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 " +"&& n%100<=10 ? 3 : n%100>=11 ? 4 : 5;\n" + +#. module: hr_dms_field +#: model_terms:ir.ui.view,arch_db:hr_dms_field.res_config_settings_view_form +msgid "Allow employees to access their DMS Documents." +msgstr "" + +#. module: hr_dms_field +#: model:ir.model,name:hr_dms_field.model_hr_employee_base +msgid "Basic Employee" +msgstr "" + +#. module: hr_dms_field +#: model:ir.model,name:hr_dms_field.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: hr_dms_field +#: model:ir.model.fields,field_description:hr_dms_field.field_hr_employee_base__dms_directory_ids +msgid "DMS Directories" +msgstr "" + +#. module: hr_dms_field +#: model:res.groups,name:hr_dms_field.group_hr_public_dms +msgid "DMS Is accessible publicly on employee profile" +msgstr "" + +#. module: hr_dms_field +#: model_terms:ir.ui.view,arch_db:hr_dms_field.hr_employee_public_view_form +#: model_terms:ir.ui.view,arch_db:hr_dms_field.view_employee_form +msgid "Documents" +msgstr "" + +#. module: hr_dms_field +#: model:dms.access.group,name:hr_dms_field.read_access_hr_employee_group +msgid "Everyone for Employee DMS" +msgstr "" + +#. module: hr_dms_field +#: model:ir.model.fields,field_description:hr_dms_field.field_hr_employee_public__is_logged +msgid "Is Logged" +msgstr "" + +#. module: hr_dms_field +#: model:ir.model,name:hr_dms_field.model_hr_employee_public +msgid "Public Employee" +msgstr "" + +#. module: hr_dms_field +#: model:ir.model.fields,field_description:hr_dms_field.field_res_config_settings__group_hr_public_dms +msgid "Show DMS Documents to logged employees" +msgstr "" diff --git a/hr_dms_field/i18n/es.po b/hr_dms_field/i18n/es.po new file mode 100644 index 000000000..fc6bc42f2 --- /dev/null +++ b/hr_dms_field/i18n/es.po @@ -0,0 +1,69 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_dms_field +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-02-07 16:03+0000\n" +"PO-Revision-Date: 2026-04-22 14:45+0000\n" +"Last-Translator: Ed-Spain \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.15.2\n" + +#. module: hr_dms_field +#: model_terms:ir.ui.view,arch_db:hr_dms_field.res_config_settings_view_form +msgid "Allow employees to access their DMS Documents." +msgstr "Permitir a los empleados acceder a sus Documentos DMS." + +#. module: hr_dms_field +#: model:ir.model,name:hr_dms_field.model_hr_employee_base +msgid "Basic Employee" +msgstr "Empleado Básico" + +#. module: hr_dms_field +#: model:ir.model,name:hr_dms_field.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: hr_dms_field +#: model:ir.model.fields,field_description:hr_dms_field.field_hr_employee_base__dms_directory_ids +msgid "DMS Directories" +msgstr "Directorios DMS" + +#. module: hr_dms_field +#: model:res.groups,name:hr_dms_field.group_hr_public_dms +msgid "DMS Is accessible publicly on employee profile" +msgstr "DMS es accesible públicamente en el perfil del empleado" + +#. module: hr_dms_field +#: model_terms:ir.ui.view,arch_db:hr_dms_field.hr_employee_public_view_form +#: model_terms:ir.ui.view,arch_db:hr_dms_field.view_employee_form +msgid "Documents" +msgstr "Documentos" + +#. module: hr_dms_field +#: model:dms.access.group,name:hr_dms_field.read_access_hr_employee_group +msgid "Everyone for Employee DMS" +msgstr "Todos para empleados DMS" + +#. module: hr_dms_field +#: model:ir.model.fields,field_description:hr_dms_field.field_hr_employee_public__is_logged +msgid "Is Logged" +msgstr "Está registrado/a" + +#. module: hr_dms_field +#: model:ir.model,name:hr_dms_field.model_hr_employee_public +msgid "Public Employee" +msgstr "Empleado Público" + +#. module: hr_dms_field +#: model:ir.model.fields,field_description:hr_dms_field.field_res_config_settings__group_hr_public_dms +msgid "Show DMS Documents to logged employees" +msgstr "Mostrar documentos DMS a las empleados logeados" diff --git a/hr_dms_field/i18n/hr_dms_field.pot b/hr_dms_field/i18n/hr_dms_field.pot new file mode 100644 index 000000000..4a3275e4a --- /dev/null +++ b/hr_dms_field/i18n/hr_dms_field.pot @@ -0,0 +1,65 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_dms_field +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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: hr_dms_field +#: model_terms:ir.ui.view,arch_db:hr_dms_field.res_config_settings_view_form +msgid "Allow employees to access their DMS Documents." +msgstr "" + +#. module: hr_dms_field +#: model:ir.model,name:hr_dms_field.model_hr_employee_base +msgid "Basic Employee" +msgstr "" + +#. module: hr_dms_field +#: model:ir.model,name:hr_dms_field.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: hr_dms_field +#: model:ir.model.fields,field_description:hr_dms_field.field_hr_employee_base__dms_directory_ids +msgid "DMS Directories" +msgstr "" + +#. module: hr_dms_field +#: model:res.groups,name:hr_dms_field.group_hr_public_dms +msgid "DMS Is accessible publicly on employee profile" +msgstr "" + +#. module: hr_dms_field +#: model_terms:ir.ui.view,arch_db:hr_dms_field.hr_employee_public_view_form +#: model_terms:ir.ui.view,arch_db:hr_dms_field.view_employee_form +msgid "Documents" +msgstr "" + +#. module: hr_dms_field +#: model:dms.access.group,name:hr_dms_field.read_access_hr_employee_group +msgid "Everyone for Employee DMS" +msgstr "" + +#. module: hr_dms_field +#: model:ir.model.fields,field_description:hr_dms_field.field_hr_employee_public__is_logged +msgid "Is Logged" +msgstr "" + +#. module: hr_dms_field +#: model:ir.model,name:hr_dms_field.model_hr_employee_public +msgid "Public Employee" +msgstr "" + +#. module: hr_dms_field +#: model:ir.model.fields,field_description:hr_dms_field.field_res_config_settings__group_hr_public_dms +msgid "Show DMS Documents to logged employees" +msgstr "" diff --git a/hr_dms_field/i18n/it.po b/hr_dms_field/i18n/it.po new file mode 100644 index 000000000..76558def1 --- /dev/null +++ b/hr_dms_field/i18n/it.po @@ -0,0 +1,68 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_dms_field +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-04-05 11:06+0000\n" +"Last-Translator: mymage \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 5.10.2\n" + +#. module: hr_dms_field +#: model_terms:ir.ui.view,arch_db:hr_dms_field.res_config_settings_view_form +msgid "Allow employees to access their DMS Documents." +msgstr "Consente ai dipendenti di accedere ai propri documenti DMS." + +#. module: hr_dms_field +#: model:ir.model,name:hr_dms_field.model_hr_employee_base +msgid "Basic Employee" +msgstr "Dipendente base" + +#. module: hr_dms_field +#: model:ir.model,name:hr_dms_field.model_res_config_settings +msgid "Config Settings" +msgstr "Impostazioni configurazione" + +#. module: hr_dms_field +#: model:ir.model.fields,field_description:hr_dms_field.field_hr_employee_base__dms_directory_ids +msgid "DMS Directories" +msgstr "Cartelle DMS" + +#. module: hr_dms_field +#: model:res.groups,name:hr_dms_field.group_hr_public_dms +msgid "DMS Is accessible publicly on employee profile" +msgstr "DMS è accessibile pubblicamente nel profilo dipendente" + +#. module: hr_dms_field +#: model_terms:ir.ui.view,arch_db:hr_dms_field.hr_employee_public_view_form +#: model_terms:ir.ui.view,arch_db:hr_dms_field.view_employee_form +msgid "Documents" +msgstr "Documenti" + +#. module: hr_dms_field +#: model:dms.access.group,name:hr_dms_field.read_access_hr_employee_group +msgid "Everyone for Employee DMS" +msgstr "Tutti per il DMS dei dipendenti" + +#. module: hr_dms_field +#: model:ir.model.fields,field_description:hr_dms_field.field_hr_employee_public__is_logged +msgid "Is Logged" +msgstr "È collegato" + +#. module: hr_dms_field +#: model:ir.model,name:hr_dms_field.model_hr_employee_public +msgid "Public Employee" +msgstr "Dipendente pubblico" + +#. module: hr_dms_field +#: model:ir.model.fields,field_description:hr_dms_field.field_res_config_settings__group_hr_public_dms +msgid "Show DMS Documents to logged employees" +msgstr "Mostra i documenti DMS ai dipendenti collegati" diff --git a/hr_dms_field/i18n/sl.po b/hr_dms_field/i18n/sl.po new file mode 100644 index 000000000..947ae8401 --- /dev/null +++ b/hr_dms_field/i18n/sl.po @@ -0,0 +1,71 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_dms_field +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2026-06-22 09:25+0000\n" +"Last-Translator: Matjaz Mozetic \n" +"Language-Team: none\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || " +"n%100==4 ? 2 : 3;\n" +"X-Generator: Weblate 5.15.2\n" + +#. module: hr_dms_field +#: model_terms:ir.ui.view,arch_db:hr_dms_field.res_config_settings_view_form +msgid "Allow employees to access their DMS Documents." +msgstr "" +"Zaposlenim omogočite dostop do njihovih dokumentov v sistemu za upravljanje " +"dokumentov (DMS)." + +#. module: hr_dms_field +#: model:ir.model,name:hr_dms_field.model_hr_employee_base +msgid "Basic Employee" +msgstr "Osnovni zaposleni" + +#. module: hr_dms_field +#: model:ir.model,name:hr_dms_field.model_res_config_settings +msgid "Config Settings" +msgstr "Nastavitve" + +#. module: hr_dms_field +#: model:ir.model.fields,field_description:hr_dms_field.field_hr_employee_base__dms_directory_ids +msgid "DMS Directories" +msgstr "DMS mape" + +#. module: hr_dms_field +#: model:res.groups,name:hr_dms_field.group_hr_public_dms +msgid "DMS Is accessible publicly on employee profile" +msgstr "DMS je javno dostopen v profilu zaposlenega" + +#. module: hr_dms_field +#: model_terms:ir.ui.view,arch_db:hr_dms_field.hr_employee_public_view_form +#: model_terms:ir.ui.view,arch_db:hr_dms_field.view_employee_form +msgid "Documents" +msgstr "Dokumenti" + +#. module: hr_dms_field +#: model:dms.access.group,name:hr_dms_field.read_access_hr_employee_group +msgid "Everyone for Employee DMS" +msgstr "Vsi za DMS zaposlenih" + +#. module: hr_dms_field +#: model:ir.model.fields,field_description:hr_dms_field.field_hr_employee_public__is_logged +msgid "Is Logged" +msgstr "Je prijavljen" + +#. module: hr_dms_field +#: model:ir.model,name:hr_dms_field.model_hr_employee_public +msgid "Public Employee" +msgstr "Javni uslužbenec" + +#. module: hr_dms_field +#: model:ir.model.fields,field_description:hr_dms_field.field_res_config_settings__group_hr_public_dms +msgid "Show DMS Documents to logged employees" +msgstr "Prikaži dokumente DMS prijavljenim zaposlenim" diff --git a/hr_dms_field/models/__init__.py b/hr_dms_field/models/__init__.py new file mode 100644 index 000000000..4b0c3964b --- /dev/null +++ b/hr_dms_field/models/__init__.py @@ -0,0 +1,5 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import hr_employee +from . import hr_employee_public +from . import res_config_settings diff --git a/hr_dms_field/models/hr_employee.py b/hr_dms_field/models/hr_employee.py new file mode 100644 index 000000000..0e6d9856c --- /dev/null +++ b/hr_dms_field/models/hr_employee.py @@ -0,0 +1,9 @@ +# Copyright 2024 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class HrEmployeeBase(models.AbstractModel): + _name = "hr.employee.base" + _inherit = ["hr.employee.base", "dms.field.mixin"] diff --git a/hr_dms_field/models/hr_employee_public.py b/hr_dms_field/models/hr_employee_public.py new file mode 100644 index 000000000..83fd1a448 --- /dev/null +++ b/hr_dms_field/models/hr_employee_public.py @@ -0,0 +1,16 @@ +# Copyright 2024 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class HrEmployeePublic(models.Model): + _inherit = "hr.employee.public" + + is_logged = fields.Boolean(compute="_compute_is_logged", store=False) + + def _compute_is_logged(self): + self.is_logged = False + for record in self: + if self.env.user == record.user_id: + record.is_logged = True diff --git a/hr_dms_field/models/res_config_settings.py b/hr_dms_field/models/res_config_settings.py new file mode 100644 index 000000000..2e947130c --- /dev/null +++ b/hr_dms_field/models/res_config_settings.py @@ -0,0 +1,12 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + group_hr_public_dms = fields.Boolean( + string="Show DMS Documents to logged employees", + implied_group="hr_dms_field.group_hr_public_dms", + ) diff --git a/hr_dms_field/pyproject.toml b/hr_dms_field/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/hr_dms_field/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/hr_dms_field/readme/CONFIGURE.md b/hr_dms_field/readme/CONFIGURE.md new file mode 100644 index 000000000..23bf738ac --- /dev/null +++ b/hr_dms_field/readme/CONFIGURE.md @@ -0,0 +1,8 @@ +1. *Go to Documents \> Configuration \> File templates* and create a + new record. +2. Set a storage, a model (hr.employee) and the access groups you want. +3. Click on the "Documents" tab icon and a folder hierarchy will be + created. +4. You can set here the hierarchy of directories, subdirectories and + files you need, this hierarchy will be used as a base when creating + a new record (res.partner for example). diff --git a/hr_dms_field/readme/CONTRIBUTORS.md b/hr_dms_field/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..5fee39042 --- /dev/null +++ b/hr_dms_field/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [Tecnativa](https://www.tecnativa.com): + - Víctor Martínez + - Pedro M. Baeza diff --git a/hr_dms_field/readme/DESCRIPTION.md b/hr_dms_field/readme/DESCRIPTION.md new file mode 100644 index 000000000..4769e05dc --- /dev/null +++ b/hr_dms_field/readme/DESCRIPTION.md @@ -0,0 +1 @@ +Add the Documents tab with the files in the employee's form view. diff --git a/hr_dms_field/readme/USAGE.md b/hr_dms_field/readme/USAGE.md new file mode 100644 index 000000000..bb33eaa0f --- /dev/null +++ b/hr_dms_field/readme/USAGE.md @@ -0,0 +1,4 @@ +#\. Go to the form view of an existing employee and click on the +"Documents" tab icon, a hierarchy of folders and files linked to that +record will be created. \#. Create a new employee. A hierarchy of +folders and files linked to that record will be created. diff --git a/hr_dms_field/security/security.xml b/hr_dms_field/security/security.xml new file mode 100644 index 000000000..6b1ac3002 --- /dev/null +++ b/hr_dms_field/security/security.xml @@ -0,0 +1,17 @@ + + + + + DMS Is accessible publicly on employee profile + + + + + + + + + diff --git a/hr_dms_field/static/description/icon.png b/hr_dms_field/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/hr_dms_field/static/description/icon.png differ diff --git a/hr_dms_field/static/description/index.html b/hr_dms_field/static/description/index.html new file mode 100644 index 000000000..68604c591 --- /dev/null +++ b/hr_dms_field/static/description/index.html @@ -0,0 +1,451 @@ + + + + + +Add dms field for employees + + + +
+

Add dms field for employees

+ + +

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

+

Add the Documents tab with the files in the employee’s form view.

+

Table of contents

+ +
+

Configuration

+
    +
  1. Go to Documents > Configuration > File templates and create a new +record.
  2. +
  3. Set a storage, a model (hr.employee) and the access groups you want.
  4. +
  5. Click on the “Documents” tab icon and a folder hierarchy will be +created.
  6. +
  7. You can set here the hierarchy of directories, subdirectories and +files you need, this hierarchy will be used as a base when creating a +new record (res.partner for example).
  8. +
+
+
+

Usage

+

#. Go to the form view of an existing employee and click on the +“Documents” tab icon, a hierarchy of folders and files linked to that +record will be created. #. Create a new employee. A hierarchy of folders +and files linked to that record will be created.

+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Víctor Martínez
    • +
    • Pedro M. Baeza
    • +
    +
  • +
+
+
+

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.

+

Current maintainer:

+

victoralmau

+

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

+

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

+
+
+
+ + diff --git a/hr_dms_field/static/src/js/base/dms_list_controller.esm.js b/hr_dms_field/static/src/js/base/dms_list_controller.esm.js new file mode 100644 index 000000000..8526c937d --- /dev/null +++ b/hr_dms_field/static/src/js/base/dms_list_controller.esm.js @@ -0,0 +1,20 @@ +import {DmsListController} from "@dms_field/views/dms_list/dms_list_controller.esm"; +import {X2ManyField} from "@web/views/fields/x2many/x2many_field"; +import {patch} from "@web/core/utils/patch"; + +function getSanitizeDMSModel() { + return { + // A basic user does not have access to hr.employee, only to hr.employee.public + // (Employee Directory), we have to get the data from hr.employee because that + // is where it is actually linked. + sanitizeDMSModel(model) { + if (model === "hr.employee.public") { + return "hr.employee"; + } + return super.sanitizeDMSModel(...arguments); + }, + }; +} + +patch(DmsListController.prototype, getSanitizeDMSModel()); +patch(X2ManyField.prototype, getSanitizeDMSModel()); diff --git a/hr_dms_field/tests/__init__.py b/hr_dms_field/tests/__init__.py new file mode 100644 index 000000000..788e27983 --- /dev/null +++ b/hr_dms_field/tests/__init__.py @@ -0,0 +1 @@ +from . import test_hr_dms_field diff --git a/hr_dms_field/tests/test_hr_dms_field.py b/hr_dms_field/tests/test_hr_dms_field.py new file mode 100644 index 000000000..e8a818718 --- /dev/null +++ b/hr_dms_field/tests/test_hr_dms_field.py @@ -0,0 +1,113 @@ +# Copyright 2024-2025 Tecnativa - Víctor Martínez +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). +from odoo import Command +from odoo.tests import new_test_user +from odoo.tools import mute_logger + +from odoo.addons.base.tests.common import BaseCommon + + +class TestHrDmsField(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, test_dms_field=True)) + cls.template = cls.env.ref("hr_dms_field.field_template_employee") + cls.storage = cls.template.storage_id + cls.access_group = cls.template.group_ids + cls.env["dms.directory"].create( + { + "name": "Payrolls", + "parent_id": cls.template.dms_directory_ids[0].id, + "storage_id": cls.template.storage_id.id, + } + ) + cls.env["dms.directory"].create( + { + "name": "Contracts", + "parent_id": cls.template.dms_directory_ids[0].id, + "storage_id": cls.template.storage_id.id, + } + ) + cls.user = new_test_user(cls.env, login="test-user") + cls.employee_model = cls.env["hr.employee"] + + def test_employee_exists(self): + employee = self.employee_model.search([], limit=1) + self.assertEqual(len(employee.dms_directory_ids), 0) + + def test_employee_create_01(self): + employee = self.employee_model.create({"name": "Test employee"}) + # Manually refresh, similar to UX + # dms_field/static/src/views/dms_list/dms_list_renderer.esm.js#L450 + employee.invalidate_model() + directory = employee.dms_directory_ids + self.assertEqual(len(directory), 1) + self.assertEqual(directory.storage_id, self.storage) + group_custom = directory.group_ids.filtered("dms_field_ref") + self.assertIn(self.access_group, directory.group_ids) + self.assertNotIn(self.user, group_custom.explicit_user_ids) + child_directory_names = directory.mapped("child_directory_ids.name") + self.assertIn("Payrolls", child_directory_names) + self.assertIn("Contracts", child_directory_names) + + def test_employee_create_02(self): + employee = self.employee_model.create( + { + "name": "Test employee", + "user_id": self.user.id, + } + ) + # Manually refresh, similar to UX + # dms_field/static/src/views/dms_list/dms_list_renderer.esm.js#L450 + employee.invalidate_model() + group_custom = employee.dms_directory_ids.group_ids.filtered("dms_field_ref") + self.assertIn(self.user, group_custom.explicit_user_ids) + + def test_employee_write_custom(self): + read_access_hr_employee_group = self.env.ref( + "hr_dms_field.read_access_hr_employee_group" + ) + read_access_hr_employee_group.write( + { + "group_ids": [Command.set([])], + "explicit_user_ids": [Command.set(self.env.ref("base.user_admin").ids)], + } + ) + employee = self.employee_model.create({"name": "Test employee"}) + employee.invalidate_recordset() + directory = employee.dms_directory_ids + self.assertEqual(len(directory), 1) + directory_0 = employee.dms_directory_ids[0] + group_custom = directory_0.group_ids.filtered("dms_field_ref") + self.assertFalse(group_custom.explicit_user_ids) + # Use the demo user to modify the employee and link the user, it does not + # have access to the directory. + demo = self.env.ref("base.user_demo") + demo.write({"group_ids": [Command.link(self.env.ref("hr.group_hr_user").id)]}) + employee = employee.with_user(demo) + employee.invalidate_recordset() + employee.write({"user_id": self.user.id}) + self.assertIn(self.user, group_custom.explicit_user_ids) + + @mute_logger("odoo.models.unlink") + def test_employee_full_process(self): + employee = self.employee_model.create( + { + "name": "Test employee", + "user_id": self.user.id, + } + ) + # Manually refresh, similar to UX + # dms_field/static/src/views/dms_list/dms_list_renderer.esm.js#L450 + employee.invalidate_model() + directory_0 = employee.dms_directory_ids[0] + group_custom = directory_0.group_ids.filtered("dms_field_ref") + self.assertIn(self.user, group_custom.explicit_user_ids) + employee.write({"user_id": False}) + self.assertFalse(group_custom.explicit_user_ids) + employee.write({"user_id": self.user.id}) + self.assertIn(self.user, group_custom.explicit_user_ids) + employee.unlink() + self.assertFalse(directory_0.exists()) + self.assertFalse(group_custom.exists()) diff --git a/hr_dms_field/views/hr_employee_view.xml b/hr_dms_field/views/hr_employee_view.xml new file mode 100644 index 000000000..edb4cdbb3 --- /dev/null +++ b/hr_dms_field/views/hr_employee_view.xml @@ -0,0 +1,40 @@ + + + + hr.employee.form + hr.employee + + + + + + + + + + + hr.employee.public.form + hr.employee.public + + + + + + + + + + + + + + diff --git a/hr_dms_field/views/res_config_settings_view.xml b/hr_dms_field/views/res_config_settings_view.xml new file mode 100644 index 000000000..1d7e9b172 --- /dev/null +++ b/hr_dms_field/views/res_config_settings_view.xml @@ -0,0 +1,27 @@ + + + + res.config.settings.view.form.inherit.hr + res.config.settings + + + + +
+
+ +
+
+
+
+
+
+
+