diff --git a/base_user_role_history/README.rst b/base_user_role_history/README.rst new file mode 100644 index 000000000..ae5632fec --- /dev/null +++ b/base_user_role_history/README.rst @@ -0,0 +1,103 @@ +====================== +Base User Role History +====================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:db5f768a177dfcc1ad17e65d53bedeeac1d7d840e0d009dba5338d27478a0382 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fserver--backend-lightgray.png?logo=github + :target: https://github.com/OCA/server-backend/tree/17.0/base_user_role_history + :alt: OCA/server-backend +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-backend-17-0/server-backend-17-0-base_user_role_history + :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/server-backend&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This addon provides history for roles modifications on users. Each time +a role is added/updated/unlinked on a user, a new role history line is +created mentioning what changes were made and who made them. Theses +informations are directly accessible from users via a smart button. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Changes on user roles are easily accessible via a button on user form +view. + +Known issues / Roadmap +====================== + +Since roles on role history line have 'cascade' ondelete, role deletion +leads to role history line deletion. In order to keep history even in +the case of a role deletion, module could be upgraded. + +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 +------------ + +- Benoit Aimont (https://acsone.eu) +- Thomas Binsfeld (https://acsone.eu) +- Christopher Rogos (https://glueckkanja.com) +- Mohamed Osman (https://glueckkanja.com) + +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-ThomasBinsfeld| image:: https://github.com/ThomasBinsfeld.png?size=40px + :target: https://github.com/ThomasBinsfeld + :alt: ThomasBinsfeld + +Current `maintainer `__: + +|maintainer-ThomasBinsfeld| + +This module is part of the `OCA/server-backend `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_user_role_history/__init__.py b/base_user_role_history/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/base_user_role_history/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/base_user_role_history/__manifest__.py b/base_user_role_history/__manifest__.py new file mode 100644 index 000000000..3ef780948 --- /dev/null +++ b/base_user_role_history/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright 2019 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Base User Role History", + "summary": """ + This module allows to track the changes on users roles.""", + "version": "17.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV, " "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/server-backend", + "depends": [ + # Odoo + "mail", + # OCA + "base_user_role", + ], + "data": [ + "security/base_user_role_line_history.xml", + "views/base_user_role_line_history.xml", + "views/res_users.xml", + ], + "development_status": "Beta", + "maintainers": ["ThomasBinsfeld"], +} diff --git a/base_user_role_history/i18n/base_user_role_history.pot b/base_user_role_history/i18n/base_user_role_history.pot new file mode 100644 index 000000000..a8bd6d6fb --- /dev/null +++ b/base_user_role_history/i18n/base_user_role_history.pot @@ -0,0 +1,163 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_user_role_history +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.res_users_form_view +msgid "Last update of roles" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__performed_action +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "Action" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_is_enabled +msgid "Active after edit" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_is_enabled +msgid "Active before edit" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields.selection,name:base_user_role_history.selection__base_user_role_line_history__performed_action__add +msgid "Add" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__create_uid +msgid "Created by" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__create_date +msgid "Created on" +msgstr "" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_form_view +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_tree_view +msgid "Date and time of edition" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields.selection,name:base_user_role_history.selection__base_user_role_line_history__performed_action__unlink +msgid "Delete" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__display_name +msgid "Display Name" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields.selection,name:base_user_role_history.selection__base_user_role_line_history__performed_action__edit +msgid "Edit" +msgstr "" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_form_view +msgid "Edited user" +msgstr "" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_form_view +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_tree_view +msgid "Editor" +msgstr "" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "Group By" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model,name:base_user_role_history.model_base_user_role_line_history +msgid "History of user roles" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__id +msgid "ID" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history____last_update +msgid "Last Modified on" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__write_date +msgid "Last Updated on" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_res_users__last_role_line_modification +msgid "Last roles modification" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_date_to +msgid "New end date" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_role_id +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "New role" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_date_from +msgid "New start date" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_date_to +msgid "Old end date" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_role_id +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "Old role" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_date_from +msgid "Old start date" +msgstr "" + +#. module: base_user_role_history +#. odoo-python +#: code:addons/base_user_role_history/models/res_users.py:0 +#: model_terms:ir.ui.view,arch_db:base_user_role_history.res_users_form_view +#, python-format +msgid "Roles history" +msgstr "" + +#. module: base_user_role_history +#: model:ir.model,name:base_user_role_history.model_res_users +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__user_id +msgid "User" +msgstr "" diff --git a/base_user_role_history/i18n/es.po b/base_user_role_history/i18n/es.po new file mode 100644 index 000000000..cbf31d485 --- /dev/null +++ b/base_user_role_history/i18n/es.po @@ -0,0 +1,169 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_user_role_history +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-03-16 18:45+0000\n" +"Last-Translator: Ana Suárez \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.3.2\n" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.res_users_form_view +msgid "Last update of roles" +msgstr "Última actualización de roles" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__performed_action +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "Action" +msgstr "Acción" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_is_enabled +msgid "Active after edit" +msgstr "Activo después de editar" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_is_enabled +msgid "Active before edit" +msgstr "Activo antes de editar" + +#. module: base_user_role_history +#: model:ir.model.fields.selection,name:base_user_role_history.selection__base_user_role_line_history__performed_action__add +msgid "Add" +msgstr "Añadir" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__create_date +msgid "Created on" +msgstr "Creado el" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_form_view +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_tree_view +msgid "Date and time of edition" +msgstr "Fecha y hora de edición" + +#. module: base_user_role_history +#: model:ir.model.fields.selection,name:base_user_role_history.selection__base_user_role_line_history__performed_action__unlink +msgid "Delete" +msgstr "Eliminar" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__display_name +msgid "Display Name" +msgstr "Nombre mostrado" + +#. module: base_user_role_history +#: model:ir.model.fields.selection,name:base_user_role_history.selection__base_user_role_line_history__performed_action__edit +msgid "Edit" +msgstr "Editar" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_form_view +msgid "Edited user" +msgstr "Usuario editado" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_form_view +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_tree_view +msgid "Editor" +msgstr "Editor" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "Group By" +msgstr "Agrupar por" + +#. module: base_user_role_history +#: model:ir.model,name:base_user_role_history.model_base_user_role_line_history +msgid "History of user roles" +msgstr "Historial de roles" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__id +msgid "ID" +msgstr "ID" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history____last_update +msgid "Last Modified on" +msgstr "Última modificación el" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__write_uid +msgid "Last Updated by" +msgstr "Última actualización por" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__write_date +msgid "Last Updated on" +msgstr "Última actualización el" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_res_users__last_role_line_modification +msgid "Last roles modification" +msgstr "Última modificación roles" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_date_to +msgid "New end date" +msgstr "Nueva fecha fin" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_role_id +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "New role" +msgstr "Nuevo rol" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_date_from +msgid "New start date" +msgstr "Nueva fecha inicio" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_date_to +msgid "Old end date" +msgstr "Antigua fecha fin" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_role_id +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "Old role" +msgstr "Antiguo rol" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_date_from +msgid "Old start date" +msgstr "Antigua fecha inicio" + +#. module: base_user_role_history +#. odoo-python +#: code:addons/base_user_role_history/models/res_users.py:0 +#: model_terms:ir.ui.view,arch_db:base_user_role_history.res_users_form_view +#, python-format +msgid "Roles history" +msgstr "Historial Roles" + +#. module: base_user_role_history +#: model:ir.model,name:base_user_role_history.model_res_users +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__user_id +msgid "User" +msgstr "Usuario" + +#~ msgid "Users" +#~ msgstr "Usuarios" diff --git a/base_user_role_history/i18n/fr.po b/base_user_role_history/i18n/fr.po new file mode 100644 index 000000000..0a6801e34 --- /dev/null +++ b/base_user_role_history/i18n/fr.po @@ -0,0 +1,169 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_user_role_history +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-12-18 11:07+0000\n" +"PO-Revision-Date: 2019-09-30 11:51+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.res_users_form_view +msgid "Last update of roles" +msgstr "Dernière modification des rôles" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__performed_action +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "Action" +msgstr "Action" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_is_enabled +msgid "Active after edit" +msgstr "Actif après édition" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_is_enabled +msgid "Active before edit" +msgstr "Actif avant édition" + +#. module: base_user_role_history +#: model:ir.model.fields.selection,name:base_user_role_history.selection__base_user_role_line_history__performed_action__add +msgid "Add" +msgstr "Ajouter" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__create_uid +msgid "Created by" +msgstr "Créé par" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__create_date +msgid "Created on" +msgstr "Créé le" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_form_view +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_tree_view +msgid "Date and time of edition" +msgstr "Date et heure de modification" + +#. module: base_user_role_history +#: model:ir.model.fields.selection,name:base_user_role_history.selection__base_user_role_line_history__performed_action__unlink +msgid "Delete" +msgstr "Supprimer" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: base_user_role_history +#: model:ir.model.fields.selection,name:base_user_role_history.selection__base_user_role_line_history__performed_action__edit +msgid "Edit" +msgstr "Modifier" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_form_view +msgid "Edited user" +msgstr "Utilisateur modifié" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_form_view +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_tree_view +msgid "Editor" +msgstr "Utilisateur modificateur" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "Group By" +msgstr "Regrouper par" + +#. module: base_user_role_history +#: model:ir.model,name:base_user_role_history.model_base_user_role_line_history +msgid "History of user roles" +msgstr "Historique des rôles de l'utilisateur" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__id +msgid "ID" +msgstr "ID" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history____last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__write_uid +msgid "Last Updated by" +msgstr "Mis à jour par" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__write_date +msgid "Last Updated on" +msgstr "Mis à jour le" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_res_users__last_role_line_modification +msgid "Last roles modification" +msgstr "Dernière modification des rôles" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_date_to +msgid "New end date" +msgstr "Nouvelle date de fin" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_role_id +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "New role" +msgstr "Nouveau rôle" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_date_from +msgid "New start date" +msgstr "Nouvelle date de début" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_date_to +msgid "Old end date" +msgstr "Ancienne date de fin" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_role_id +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "Old role" +msgstr "Ancien rôle" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_date_from +msgid "Old start date" +msgstr "Ancienne date de début" + +#. module: base_user_role_history +#. odoo-python +#: code:addons/base_user_role_history/models/res_users.py:0 +#: model_terms:ir.ui.view,arch_db:base_user_role_history.res_users_form_view +#, python-format +msgid "Roles history" +msgstr "Historique des rôles" + +#. module: base_user_role_history +#: model:ir.model,name:base_user_role_history.model_res_users +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__user_id +msgid "User" +msgstr "Utilisateur" + +#~ msgid "Users" +#~ msgstr "Utilisateurs" diff --git a/base_user_role_history/i18n/fr_BE.po b/base_user_role_history/i18n/fr_BE.po new file mode 100644 index 000000000..ca0775078 --- /dev/null +++ b/base_user_role_history/i18n/fr_BE.po @@ -0,0 +1,169 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_user_role_history +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-12-18 11:07+0000\n" +"PO-Revision-Date: 2019-09-30 11:50+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"Language: fr_BE\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.res_users_form_view +msgid "Last update of roles" +msgstr "Dernière modification des rôles" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__performed_action +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "Action" +msgstr "Action" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_is_enabled +msgid "Active after edit" +msgstr "Actif après édition" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_is_enabled +msgid "Active before edit" +msgstr "Actif avant édition" + +#. module: base_user_role_history +#: model:ir.model.fields.selection,name:base_user_role_history.selection__base_user_role_line_history__performed_action__add +msgid "Add" +msgstr "Ajouter" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__create_uid +msgid "Created by" +msgstr "Créé par" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__create_date +msgid "Created on" +msgstr "Créé le" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_form_view +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_tree_view +msgid "Date and time of edition" +msgstr "Date et heure de modification" + +#. module: base_user_role_history +#: model:ir.model.fields.selection,name:base_user_role_history.selection__base_user_role_line_history__performed_action__unlink +msgid "Delete" +msgstr "Supprimer" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: base_user_role_history +#: model:ir.model.fields.selection,name:base_user_role_history.selection__base_user_role_line_history__performed_action__edit +msgid "Edit" +msgstr "Modifier" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_form_view +msgid "Edited user" +msgstr "Utilisateur modifié" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_form_view +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_tree_view +msgid "Editor" +msgstr "Utilisateur modificateur" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "Group By" +msgstr "Regrouper par" + +#. module: base_user_role_history +#: model:ir.model,name:base_user_role_history.model_base_user_role_line_history +msgid "History of user roles" +msgstr "Historique des rôles de l'utilisateur" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__id +msgid "ID" +msgstr "ID" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history____last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__write_uid +msgid "Last Updated by" +msgstr "Derniere fois mis à jour par" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__write_date +msgid "Last Updated on" +msgstr "Dernière mis à jour le" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_res_users__last_role_line_modification +msgid "Last roles modification" +msgstr "Dernière modification des rôles" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_date_to +msgid "New end date" +msgstr "Nouvelle date de fin" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_role_id +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "New role" +msgstr "Nouveau rôle" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_date_from +msgid "New start date" +msgstr "Nouvelle date de début" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_date_to +msgid "Old end date" +msgstr "Ancienne date de fin" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_role_id +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "Old role" +msgstr "Ancien rôle" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_date_from +msgid "Old start date" +msgstr "Ancienne date de début" + +#. module: base_user_role_history +#. odoo-python +#: code:addons/base_user_role_history/models/res_users.py:0 +#: model_terms:ir.ui.view,arch_db:base_user_role_history.res_users_form_view +#, python-format +msgid "Roles history" +msgstr "Historique des rôles" + +#. module: base_user_role_history +#: model:ir.model,name:base_user_role_history.model_res_users +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__user_id +msgid "User" +msgstr "Utilisateur" + +#~ msgid "Users" +#~ msgstr "Utilisateurs" diff --git a/base_user_role_history/i18n/it.po b/base_user_role_history/i18n/it.po new file mode 100644 index 000000000..5383108b8 --- /dev/null +++ b/base_user_role_history/i18n/it.po @@ -0,0 +1,166 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_user_role_history +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-01-05 15:36+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 4.17\n" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.res_users_form_view +msgid "Last update of roles" +msgstr "Ultimo aggiornamento ruoli" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__performed_action +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "Action" +msgstr "Azione" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_is_enabled +msgid "Active after edit" +msgstr "Attivo dopo la modifica" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_is_enabled +msgid "Active before edit" +msgstr "Attivo prima della modifica" + +#. module: base_user_role_history +#: model:ir.model.fields.selection,name:base_user_role_history.selection__base_user_role_line_history__performed_action__add +msgid "Add" +msgstr "Aggiungi" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__create_uid +msgid "Created by" +msgstr "Creato da" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__create_date +msgid "Created on" +msgstr "Creato il" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_form_view +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_tree_view +msgid "Date and time of edition" +msgstr "Data e ora della modifica" + +#. module: base_user_role_history +#: model:ir.model.fields.selection,name:base_user_role_history.selection__base_user_role_line_history__performed_action__unlink +msgid "Delete" +msgstr "Cancella" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: base_user_role_history +#: model:ir.model.fields.selection,name:base_user_role_history.selection__base_user_role_line_history__performed_action__edit +msgid "Edit" +msgstr "Modifica" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_form_view +msgid "Edited user" +msgstr "Utente modifica" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_form_view +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_tree_view +msgid "Editor" +msgstr "Editor" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "Group By" +msgstr "Raggruppa per" + +#. module: base_user_role_history +#: model:ir.model,name:base_user_role_history.model_base_user_role_line_history +msgid "History of user roles" +msgstr "Stoico ruoli utente" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__id +msgid "ID" +msgstr "ID" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__write_uid +msgid "Last Updated by" +msgstr "Ultimo aggiornamento di" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__write_date +msgid "Last Updated on" +msgstr "Ultimo aggiornamento il" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_res_users__last_role_line_modification +msgid "Last roles modification" +msgstr "Ultime modifiche ruoli" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_date_to +msgid "New end date" +msgstr "Nuova data fine" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_role_id +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "New role" +msgstr "Nuovo ruolo" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_date_from +msgid "New start date" +msgstr "Nuova data inizio" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_date_to +msgid "Old end date" +msgstr "Vecchia data fine" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_role_id +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "Old role" +msgstr "Vecchio ruolo" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_date_from +msgid "Old start date" +msgstr "Vecchia data inisio" + +#. module: base_user_role_history +#. odoo-python +#: code:addons/base_user_role_history/models/res_users.py:0 +#: model_terms:ir.ui.view,arch_db:base_user_role_history.res_users_form_view +#, python-format +msgid "Roles history" +msgstr "Storico ruoli" + +#. module: base_user_role_history +#: model:ir.model,name:base_user_role_history.model_res_users +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__user_id +msgid "User" +msgstr "Utente" diff --git a/base_user_role_history/i18n/pt.po b/base_user_role_history/i18n/pt.po new file mode 100644 index 000000000..5329c12e4 --- /dev/null +++ b/base_user_role_history/i18n/pt.po @@ -0,0 +1,166 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_user_role_history +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-08-31 10:35+0000\n" +"Last-Translator: Pedro Castro Silva \n" +"Language-Team: none\n" +"Language: pt\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: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.res_users_form_view +msgid "Last update of roles" +msgstr "Última atualização de funções" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__performed_action +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "Action" +msgstr "Ação" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_is_enabled +msgid "Active after edit" +msgstr "Ativo após edição" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_is_enabled +msgid "Active before edit" +msgstr "Ativo antes da edição" + +#. module: base_user_role_history +#: model:ir.model.fields.selection,name:base_user_role_history.selection__base_user_role_line_history__performed_action__add +msgid "Add" +msgstr "Adicionar" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__create_uid +msgid "Created by" +msgstr "Criado por" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__create_date +msgid "Created on" +msgstr "Criado em" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_form_view +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_tree_view +msgid "Date and time of edition" +msgstr "Data e hora da edição" + +#. module: base_user_role_history +#: model:ir.model.fields.selection,name:base_user_role_history.selection__base_user_role_line_history__performed_action__unlink +msgid "Delete" +msgstr "Excluir" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__display_name +msgid "Display Name" +msgstr "Nome" + +#. module: base_user_role_history +#: model:ir.model.fields.selection,name:base_user_role_history.selection__base_user_role_line_history__performed_action__edit +msgid "Edit" +msgstr "Editar" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_form_view +msgid "Edited user" +msgstr "Utilizador editado" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_form_view +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_tree_view +msgid "Editor" +msgstr "Editor" + +#. module: base_user_role_history +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "Group By" +msgstr "Agrupar Por" + +#. module: base_user_role_history +#: model:ir.model,name:base_user_role_history.model_base_user_role_line_history +msgid "History of user roles" +msgstr "Histórico de funções de utilizador" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__id +msgid "ID" +msgstr "ID" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history____last_update +msgid "Last Modified on" +msgstr "Última Modificação em" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__write_uid +msgid "Last Updated by" +msgstr "Ultima Atualização por" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__write_date +msgid "Last Updated on" +msgstr "Última Atualização em" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_res_users__last_role_line_modification +msgid "Last roles modification" +msgstr "Última modificação de funções" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_date_to +msgid "New end date" +msgstr "Nova data de término" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_role_id +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "New role" +msgstr "Nova função" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__new_date_from +msgid "New start date" +msgstr "Nova data de início" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_date_to +msgid "Old end date" +msgstr "Antiga data de término" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_role_id +#: model_terms:ir.ui.view,arch_db:base_user_role_history.base_user_role_line_history_search_view +msgid "Old role" +msgstr "Antiga função" + +#. module: base_user_role_history +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__old_date_from +msgid "Old start date" +msgstr "Antiga data de início" + +#. module: base_user_role_history +#. odoo-python +#: code:addons/base_user_role_history/models/res_users.py:0 +#: model_terms:ir.ui.view,arch_db:base_user_role_history.res_users_form_view +#, python-format +msgid "Roles history" +msgstr "Histórico de funções" + +#. module: base_user_role_history +#: model:ir.model,name:base_user_role_history.model_res_users +#: model:ir.model.fields,field_description:base_user_role_history.field_base_user_role_line_history__user_id +msgid "User" +msgstr "Utilizador" diff --git a/base_user_role_history/models/__init__.py b/base_user_role_history/models/__init__.py new file mode 100644 index 000000000..96d05ca41 --- /dev/null +++ b/base_user_role_history/models/__init__.py @@ -0,0 +1,3 @@ +from . import res_users +from . import base_user_role_line_history +from . import res_users_role_line diff --git a/base_user_role_history/models/base_user_role_line_history.py b/base_user_role_history/models/base_user_role_line_history.py new file mode 100644 index 000000000..4302a0e62 --- /dev/null +++ b/base_user_role_history/models/base_user_role_line_history.py @@ -0,0 +1,40 @@ +# Copyright 2019 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class BaseUserRoleLineHistory(models.Model): + _name = "base.user.role.line.history" + _description = "History of user roles" + _order = "id desc" + + performed_action = fields.Selection( + string="Action", + selection=[("add", "Add"), ("unlink", "Delete"), ("edit", "Edit")], + required=True, + ) + user_id = fields.Many2one( + string="User", + comodel_name="res.users", + ondelete="cascade", + index=True, + ) + old_role_id = fields.Many2one( + string="Old role", + comodel_name="res.users.role", + ondelete="cascade", + index=True, + ) + new_role_id = fields.Many2one( + string="New role", + comodel_name="res.users.role", + ondelete="cascade", + index=True, + ) + old_date_from = fields.Date(string="Old start date") + new_date_from = fields.Date(string="New start date") + old_date_to = fields.Date(string="Old end date") + new_date_to = fields.Date(string="New end date") + old_is_enabled = fields.Boolean(string="Active before edit") + new_is_enabled = fields.Boolean(string="Active after edit") diff --git a/base_user_role_history/models/res_users.py b/base_user_role_history/models/res_users.py new file mode 100644 index 000000000..d6c90c226 --- /dev/null +++ b/base_user_role_history/models/res_users.py @@ -0,0 +1,30 @@ +# Copyright 2019 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import _, fields, models + + +class ResUsers(models.Model): + _inherit = "res.users" + + last_role_line_modification = fields.Datetime( + compute="_compute_last_role_line_modification", + ) + + def _compute_last_role_line_modification(self): + for user in self: + res = self.env["base.user.role.line.history"].search( + [("user_id", "=", user.id)], limit=1, order="id desc" + ) + user.last_role_line_modification = res.create_date if res else False + + def show_role_lines_history(self): # pragma: no cover + self.ensure_one() + domain = [("user_id", "=", self.id)] + return { + "name": _("Roles history"), + "type": "ir.actions.act_window", + "view_mode": "tree,form", + "res_model": "base.user.role.line.history", + "domain": domain, + } diff --git a/base_user_role_history/models/res_users_role_line.py b/base_user_role_history/models/res_users_role_line.py new file mode 100644 index 000000000..5747cc9aa --- /dev/null +++ b/base_user_role_history/models/res_users_role_line.py @@ -0,0 +1,72 @@ +from odoo import api, models + + +class ResUsersRoleLine(models.Model): + _inherit = "res.users.role.line" + + def write(self, vals): + history_lines = [] + for line in self: + history_line = { + "performed_action": "edit", + "user_id": line.user_id.id, + "old_role_id": line.role_id.id, + "old_date_from": line.date_from, + "old_date_to": line.date_to, + "old_is_enabled": line.is_enabled, + "new_role_id": vals.get("role_id", line.role_id.id), + "new_date_from": vals.get("date_from", line.date_from), + "new_date_to": vals.get("date_to", line.date_to), + "new_is_enabled": vals.get("is_enabled", line.is_enabled), + } + if ( + history_line["old_role_id"] == history_line["new_role_id"] + and history_line["old_date_from"] == history_line["new_date_from"] + and history_line["old_date_to"] == history_line["new_date_to"] + and history_line["old_is_enabled"] == history_line["new_is_enabled"] + ): + continue + + history_lines.append(history_line) + + res = super().write(vals) + self.env["base.user.role.line.history"].sudo().create(history_lines) + + return res + + @api.model_create_multi + def create(self, vals_list): + history_lines = [] + for line in vals_list: + history_line = { + "performed_action": "add", + "user_id": line.get("user_id", False), + "new_role_id": line.get("role_id", False), + "new_date_from": line.get("date_from", False), + "new_date_to": line.get("date_to", False), + "new_is_enabled": line.get("is_enabled", True), + } + history_lines.append(history_line) + + res = super().create(vals_list) + self.env["base.user.role.line.history"].sudo().create(history_lines) + + return res + + def unlink(self): + history_lines = [] + for line in self: + history_line = { + "performed_action": "unlink", + "user_id": line.user_id.id, + "old_role_id": line.role_id.id, + "old_date_from": line.date_from, + "old_date_to": line.date_to, + "old_is_enabled": line.is_enabled, + } + history_lines.append(history_line) + + res = super().unlink() + self.env["base.user.role.line.history"].sudo().create(history_lines) + + return res diff --git a/base_user_role_history/pyproject.toml b/base_user_role_history/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/base_user_role_history/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/base_user_role_history/readme/CONTRIBUTORS.md b/base_user_role_history/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..9492cc47c --- /dev/null +++ b/base_user_role_history/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- Benoit Aimont \<\> () +- Thomas Binsfeld \<\> () +- Christopher Rogos \<\> () +- Mohamed Osman \<\> () \ No newline at end of file diff --git a/base_user_role_history/readme/DESCRIPTION.md b/base_user_role_history/readme/DESCRIPTION.md new file mode 100644 index 000000000..d72b4c752 --- /dev/null +++ b/base_user_role_history/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +This addon provides history for roles modifications on users. Each time +a role is added/updated/unlinked on a user, a new role history line is +created mentioning what changes were made and who made them. Theses +informations are directly accessible from users via a smart button. diff --git a/base_user_role_history/readme/ROADMAP.md b/base_user_role_history/readme/ROADMAP.md new file mode 100644 index 000000000..ea18954cf --- /dev/null +++ b/base_user_role_history/readme/ROADMAP.md @@ -0,0 +1,3 @@ +Since roles on role history line have 'cascade' ondelete, role deletion +leads to role history line deletion. In order to keep history even in +the case of a role deletion, module could be upgraded. diff --git a/base_user_role_history/readme/USAGE.md b/base_user_role_history/readme/USAGE.md new file mode 100644 index 000000000..d7c0d1d86 --- /dev/null +++ b/base_user_role_history/readme/USAGE.md @@ -0,0 +1,2 @@ +Changes on user roles are easily accessible via a button on user form +view. diff --git a/base_user_role_history/security/base_user_role_line_history.xml b/base_user_role_history/security/base_user_role_line_history.xml new file mode 100644 index 000000000..5f339e2d9 --- /dev/null +++ b/base_user_role_history/security/base_user_role_line_history.xml @@ -0,0 +1,14 @@ + + + + + base.user.role.line.history access user + + + + + + + + diff --git a/base_user_role_history/static/description/icon.png b/base_user_role_history/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/base_user_role_history/static/description/icon.png differ diff --git a/base_user_role_history/static/description/index.html b/base_user_role_history/static/description/index.html new file mode 100644 index 000000000..0f9386042 --- /dev/null +++ b/base_user_role_history/static/description/index.html @@ -0,0 +1,444 @@ + + + + + +Base User Role History + + + +
+

Base User Role History

+ + +

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

+

This addon provides history for roles modifications on users. Each time +a role is added/updated/unlinked on a user, a new role history line is +created mentioning what changes were made and who made them. Theses +informations are directly accessible from users via a smart button.

+

Table of contents

+ +
+

Usage

+

Changes on user roles are easily accessible via a button on user form +view.

+
+
+

Known issues / Roadmap

+

Since roles on role history line have ‘cascade’ ondelete, role deletion +leads to role history line deletion. In order to keep history even in +the case of a role deletion, module could be upgraded.

+
+
+

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
  • +
+
+ +
+

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:

+

ThomasBinsfeld

+

This module is part of the OCA/server-backend project on GitHub.

+

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

+
+
+
+ + diff --git a/base_user_role_history/tests/__init__.py b/base_user_role_history/tests/__init__.py new file mode 100644 index 000000000..50ed093c9 --- /dev/null +++ b/base_user_role_history/tests/__init__.py @@ -0,0 +1,2 @@ +from . import test_base_user_role_history +from . import test_res_users_role diff --git a/base_user_role_history/tests/test_base_user_role_history.py b/base_user_role_history/tests/test_base_user_role_history.py new file mode 100644 index 000000000..33ee4c752 --- /dev/null +++ b/base_user_role_history/tests/test_base_user_role_history.py @@ -0,0 +1,142 @@ +# Copyright 2019 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).µ + +from datetime import date, timedelta + +from odoo.tests.common import TransactionCase + + +# DEPRECATED: This tests are deprecated but stay to show that the new code is working. +class TestBaseUserRoleHistory(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + # MODELS + + cls.history_line_model = cls.env["base.user.role.line.history"] + cls.role_model = cls.env["res.users.role"] + cls.user_model = cls.env["res.users"] + + # INSTANCE + + cls.user_01 = cls.user_model.search([("id", "!=", cls.env.user.id)], limit=1) + cls.role_01 = cls.role_model.create({"name": "Role test 01"}) + + def test_write_role_lines_on_user(self): + """ + Data : + - user with no role + Test case : + 1) add a role + 2) role modification with dates + 3) role modification with no change + 4) role unlink + Expected results : + 1) new role history line created with performed_action == 'add' + 2) new role history line created with performed_action == 'edit' + 3) no new role history line created + 4) new role history line created with performed_action == 'unlink' + """ + # 1 + history_lines_0 = self.history_line_model.search( + [("user_id", "=", self.user_01.id)] + ) + self.assertFalse(history_lines_0) + self.user_01.write({"role_line_ids": [(0, 0, {"role_id": self.role_01.id})]}) + history_lines_1 = self.history_line_model.search( + [("user_id", "=", self.user_01.id)] + ) + self.assertTrue(history_lines_1) + self.assertEqual(len(history_lines_1), 1) + self.assertEqual(history_lines_1.performed_action, "add") + self.assertFalse(history_lines_1.old_role_id) + self.assertEqual(history_lines_1.new_role_id, self.role_01) + # 2 + self.user_01.write( + { + "role_line_ids": [ + ( + 1, + self.user_01.role_line_ids[0].id, + { + "date_from": date.today(), + "date_to": date.today() + timedelta(days=5), + }, + ) + ] + } + ) + history_lines_2 = self.history_line_model.search( + [("user_id", "=", self.user_01.id), ("id", "not in", history_lines_1.ids)] + ) + self.assertTrue(history_lines_2) + self.assertEqual(len(history_lines_2), 1) + self.assertEqual(history_lines_2.performed_action, "edit") + self.assertEqual(history_lines_2.old_role_id, self.role_01) + self.assertEqual(history_lines_2.new_role_id, self.role_01) + self.assertFalse(history_lines_2.old_date_from) + self.assertEqual(history_lines_2.new_date_from, date.today()) + self.assertFalse(history_lines_2.old_date_to) + self.assertEqual(history_lines_2.new_date_to, date.today() + timedelta(days=5)) + self.user_01.write( + {"role_line_ids": [(1, self.user_01.role_line_ids[0].id, {})]} + ) + history_lines_3 = self.history_line_model.search( + [ + ("user_id", "=", self.user_01.id), + ("id", "not in", (history_lines_1 | history_lines_2).ids), + ] + ) + self.assertFalse(history_lines_3) + # 4 + self.user_01.write( + {"role_line_ids": [(2, self.user_01.role_line_ids[0].id, False)]} + ) + history_lines_4 = self.history_line_model.search( + [ + ("user_id", "=", self.user_01.id), + ("id", "not in", (history_lines_1 | history_lines_2).ids), + ] + ) + self.assertTrue(history_lines_4) + self.assertEqual(len(history_lines_4), 1) + self.assertEqual(history_lines_4.performed_action, "unlink") + self.assertEqual(history_lines_4.old_role_id, self.role_01) + self.assertFalse(history_lines_4.new_role_id) + self.assertEqual(history_lines_4.old_date_from, date.today()) + self.assertFalse(history_lines_4.new_date_from) + self.assertEqual(history_lines_4.old_date_to, date.today() + timedelta(days=5)) + self.assertFalse(history_lines_4.new_date_to) + + def test_create_role_lines_on_new_user(self): + """ + Data : / + Test case : + - create a user with a role + Expected results : + - new role history line created with performed_action == 'add' + """ + new_user = self.user_model.create( + { + "login": "new_user", + "name": "new_user", + "role_line_ids": [(0, 0, {"role_id": self.role_01.id})], + } + ) + history_lines = self.history_line_model.search([("user_id", "=", new_user.id)]) + self.assertTrue(history_lines) + self.assertEqual(len(history_lines), 1) + self.assertEqual(history_lines.performed_action, "add") + + def test_no_create_role_lines_on_new_user(self): + """ + Data : / + Test case : + - create a user without role + Expected results : + - no role history line created + """ + new_user = self.user_model.create({"login": "new_user", "name": "new_user"}) + history_lines = self.history_line_model.search([("user_id", "=", new_user.id)]) + self.assertEqual(len(history_lines), 0) diff --git a/base_user_role_history/tests/test_res_users_role.py b/base_user_role_history/tests/test_res_users_role.py new file mode 100644 index 000000000..c21a796e9 --- /dev/null +++ b/base_user_role_history/tests/test_res_users_role.py @@ -0,0 +1,181 @@ +from datetime import date + +from odoo.tests.common import TransactionCase + + +class TestResUsersRole(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.ResUsers = cls.env["res.users"] + cls.ResUsersRole = cls.env["res.users.role"] + cls.ResUsersRoleLine = cls.env["res.users.role.line"] + cls.BaseUserRoleLineHistory = cls.env["base.user.role.line.history"] + + cls.user = cls.ResUsers.create( + { + "name": "Test user 01", + "login": "test1", + } + ) + + def test_create_adds_history(self): + # act + role_01 = self.ResUsersRole.create( + {"name": "Test role 01", "line_ids": [(0, 0, {"user_id": self.user.id})]} + ) + + # assert + self.assertTrue(role_01.name, "Test role 01") + + history_lines_all = self.BaseUserRoleLineHistory.search( + [("user_id", "=", self.user.id)] + ) + self.assertEqual(len(history_lines_all), 1) + + history_line_1 = history_lines_all[0] + self.assertEqual(history_line_1.user_id, self.user) + self.assertEqual(history_line_1.performed_action, "add") + self.assertFalse(history_line_1.old_role_id) + self.assertEqual(history_line_1.new_role_id, role_01) + self.assertFalse(history_line_1.old_is_enabled) + self.assertTrue(history_line_1.new_is_enabled) + + def test_write_adds_history_entry(self): + # arrange + role_01 = self.ResUsersRole.create( + {"name": "Test role 01", "line_ids": [(0, 0, {"user_id": self.user.id})]} + ) + + role_01_line = role_01.line_ids[0] + + # act + role_01_line.write( + { + "date_from": "2024-05-01", + "date_to": "2024-05-30", + } + ) + + # assert + history_lines_all = self.BaseUserRoleLineHistory.search( + [("user_id", "=", self.user.id)] + ) + + self.assertEqual(len(history_lines_all), 2) + + history_lines_add = history_lines_all.filtered( + lambda x: x.performed_action == "edit" + ) + self.assertEqual(len(history_lines_add), 1) + + history_line_1 = history_lines_add[0] + self.assertEqual(history_line_1.performed_action, "edit") + self.assertFalse(history_line_1.old_date_from) + self.assertEqual(history_line_1.new_date_from, date(2024, 5, 1)) + self.assertFalse(history_line_1.old_date_to) + self.assertEqual(history_line_1.new_date_to, date(2024, 5, 30)) + self.assertTrue(history_line_1.old_is_enabled) + self.assertTrue(history_line_1.new_is_enabled) + + def test_write_no_history_entry(self): + # arrange + role_01 = self.ResUsersRole.create( + { + "name": "Test role 01", + "line_ids": [ + ( + 0, + 0, + { + "user_id": self.user.id, + "date_from": "2024-05-01", + "date_to": "2024-05-30", + }, + ) + ], + } + ) + + role_01_line = role_01.line_ids[0] + + # act + # write same values again + role_01_line.write( + { + "date_from": "2024-05-01", + "date_to": "2024-05-30", + } + ) + + # assert + history_lines_all = self.BaseUserRoleLineHistory.search( + [("user_id", "=", self.user.id)] + ) + + self.assertTrue(len(history_lines_all), 1) + history_lines_edit = history_lines_all.filtered( + lambda x: x.performed_action == "edit" + ) + self.assertTrue(len(history_lines_edit), 0) + + def test_create_adds_history_entry(self): + # arrange + role_01 = self.ResUsersRole.create({"name": "Test role 01", "line_ids": []}) + + # act + self.ResUsersRoleLine.create( + { + "role_id": role_01.id, + "user_id": self.user.id, + "date_from": "2024-05-01", + "date_to": "2024-05-30", + } + ) + + # assert + history_line_add = self.BaseUserRoleLineHistory.search( + [("user_id", "=", self.user.id), ("performed_action", "=", "add")] + ) + + self.assertEqual(len(history_line_add), 1) + history_line_1 = history_line_add[0] + self.assertFalse(history_line_1.old_role_id) + self.assertEqual(history_line_1.new_role_id, role_01) + self.assertFalse(history_line_1.old_date_from) + self.assertEqual(history_line_1.new_date_from, date(2024, 5, 1)) + self.assertFalse(history_line_1.old_date_to) + self.assertEqual(history_line_1.new_date_to, date(2024, 5, 30)) + self.assertFalse(history_line_1.old_is_enabled) + self.assertTrue(history_line_1.new_is_enabled) + + def test_unlink_adds_history_entry(self): + # arrange + role_01 = self.ResUsersRole.create( + {"name": "Test role 01", "line_ids": [(0, 0, {"user_id": self.user.id})]} + ) + + # act + role_01.line_ids[0].unlink() + + # assert + history_line_all = self.BaseUserRoleLineHistory.search( + [("user_id", "=", self.user.id)] + ) + + self.assertEqual(len(history_line_all), 2) + + history_lines_unlink = history_line_all.filtered( + lambda x: x.performed_action == "unlink" + ) + self.assertEqual(len(history_lines_unlink), 1) + + history_line_1 = history_lines_unlink[0] + self.assertEqual(history_line_1.old_role_id, role_01) + self.assertFalse(history_line_1.new_role_id) + self.assertFalse(history_line_1.old_date_from) + self.assertFalse(history_line_1.new_date_from) + self.assertFalse(history_line_1.old_date_to) + self.assertFalse(history_line_1.new_date_to) + self.assertTrue(history_line_1.old_is_enabled) + self.assertFalse(history_line_1.new_is_enabled) diff --git a/base_user_role_history/views/base_user_role_line_history.xml b/base_user_role_history/views/base_user_role_line_history.xml new file mode 100644 index 000000000..2eb1bd9df --- /dev/null +++ b/base_user_role_history/views/base_user_role_line_history.xml @@ -0,0 +1,92 @@ + + + + + + base.user.role.line.history.form (in base_user_role_history) + base.user.role.line.history + +
+
+
+ + + + + + + + + + + + + + + + +
+
+
+ + + base.user.role.line.history.tree (in base_user_role_history) + base.user.role.line.history + + + + + + + + + + + + + + + + + + + base.user.role.line.history.search (in base_user_role_history) + base.user.role.line.history + + + + + + + + + + + + +
diff --git a/base_user_role_history/views/res_users.xml b/base_user_role_history/views/res_users.xml new file mode 100644 index 000000000..0f659e06d --- /dev/null +++ b/base_user_role_history/views/res_users.xml @@ -0,0 +1,30 @@ + + + + + + res.users.form (in base_user_role_history) + res.users + + +
+ +
+
+
+