From bacb64c9ae52de75df1bec64390560494fed9976 Mon Sep 17 00:00:00 2001 From: Arnaud Pineux Date: Tue, 16 Aug 2022 16:27:55 +0200 Subject: [PATCH] [MIG] base_user_role_history: Migration to 16.0 --- base_user_role_history/README.rst | 10 +++++----- base_user_role_history/__manifest__.py | 2 +- .../i18n/base_user_role_history.pot | 9 +++------ base_user_role_history/i18n/es.po | 2 +- .../models/base_user_role_line_history.py | 3 +-- base_user_role_history/models/res_users.py | 17 +++++++++++------ .../static/description/index.html | 6 +++--- .../tests/test_base_user_role_history.py | 6 +++--- 8 files changed, 28 insertions(+), 27 deletions(-) diff --git a/base_user_role_history/README.rst b/base_user_role_history/README.rst index 8d59667a..196bf29d 100644 --- a/base_user_role_history/README.rst +++ b/base_user_role_history/README.rst @@ -14,13 +14,13 @@ Base User Role History :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/13.0/base_user_role_history + :target: https://github.com/OCA/server-backend/tree/16.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-13-0/server-backend-13-0-base_user_role_history + :target: https://translation.odoo-community.org/projects/server-backend-16-0/server-backend-16-0-base_user_role_history :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/253/13.0 + :target: https://runbot.odoo-community.org/runbot/253/16.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -53,7 +53,7 @@ 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 smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -92,6 +92,6 @@ Current `maintainer `__: |maintainer-ThomasBinsfeld| -This module is part of the `OCA/server-backend `_ project on GitHub. +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/__manifest__.py b/base_user_role_history/__manifest__.py index 6b74e8fa..218388d7 100644 --- a/base_user_role_history/__manifest__.py +++ b/base_user_role_history/__manifest__.py @@ -5,7 +5,7 @@ "name": "Base User Role History", "summary": """ This module allows to track the changes on users roles.""", - "version": "13.0.1.0.0", + "version": "16.0.1.0.0", "license": "AGPL-3", "author": "ACSONE SA/NV, " "Odoo Community Association (OCA)", "website": "https://github.com/OCA/server-backend", diff --git a/base_user_role_history/i18n/base_user_role_history.pot b/base_user_role_history/i18n/base_user_role_history.pot index a155070b..a8bd6d6f 100644 --- a/base_user_role_history/i18n/base_user_role_history.pot +++ b/base_user_role_history/i18n/base_user_role_history.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 13.0\n" +"Project-Id-Version: Odoo Server 16.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -149,6 +149,7 @@ 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 @@ -156,11 +157,7 @@ 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 "" - -#. module: base_user_role_history -#: model:ir.model,name:base_user_role_history.model_res_users -msgid "Users" -msgstr "" diff --git a/base_user_role_history/i18n/es.po b/base_user_role_history/i18n/es.po index 9942b679..a5e159dc 100644 --- a/base_user_role_history/i18n/es.po +++ b/base_user_role_history/i18n/es.po @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 13.0\n" +"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" 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 index 4e2e85d1..328fe5bf 100644 --- a/base_user_role_history/models/base_user_role_line_history.py +++ b/base_user_role_history/models/base_user_role_line_history.py @@ -114,5 +114,4 @@ class BaseUserRoleLineHistory(models.Model): ) # Create the history lines with sudo # (nobody has the create right) - for role_history_vals in role_history_line_vals_by_role_line.values(): - self.sudo().create(role_history_vals) + self.sudo().create(list(role_history_line_vals_by_role_line.values())) diff --git a/base_user_role_history/models/res_users.py b/base_user_role_history/models/res_users.py index 6ff60b4c..2a408287 100644 --- a/base_user_role_history/models/res_users.py +++ b/base_user_role_history/models/res_users.py @@ -34,26 +34,31 @@ class ResUsers(models.Model): @api.model_create_multi def create(self, vals_list): res = super().create(vals_list) - for vals in vals_list: - if "role_line_ids" not in vals: - return res + if all("role_line_ids" not in vals for vals in vals_list): + return res new_role_line_values_by_user = res._get_role_line_values_by_user() + new_role_line_to_create = {} + users = self.browse() + for user, lines in new_role_line_values_by_user.items(): + if lines: + new_role_line_to_create[user] = lines + user |= user self.env["base.user.role.line.history"].create_from_vals( - {}, new_role_line_values_by_user + {}, new_role_line_to_create ) - res.last_role_line_modification = fields.Datetime.now() + users.last_role_line_modification = fields.Datetime.now() return res def write(self, vals): if "role_line_ids" not in vals: return super().write(vals) old_role_line_values_by_user = self._get_role_line_values_by_user() + vals["last_role_line_modification"] = fields.Datetime.now() res = super().write(vals) new_role_line_values_by_user = self._get_role_line_values_by_user() self.env["base.user.role.line.history"].create_from_vals( old_role_line_values_by_user, new_role_line_values_by_user ) - self.write({"last_role_line_modification": fields.Datetime.now()}) return res def show_role_lines_history(self): # pragma: no cover diff --git a/base_user_role_history/static/description/index.html b/base_user_role_history/static/description/index.html index 5a41e7b1..20d074fe 100644 --- a/base_user_role_history/static/description/index.html +++ b/base_user_role_history/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

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

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. @@ -401,7 +401,7 @@ a role deletion, module could be upgraded.

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 smashing it by providing a detailed and welcomed -feedback.

+feedback.

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

@@ -428,7 +428,7 @@ 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.

+

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/test_base_user_role_history.py b/base_user_role_history/tests/test_base_user_role_history.py index c712f6b6..fa81febf 100644 --- a/base_user_role_history/tests/test_base_user_role_history.py +++ b/base_user_role_history/tests/test_base_user_role_history.py @@ -3,14 +3,14 @@ from datetime import date, timedelta -from odoo.tests.common import SavepointCase +from odoo.tests.common import TransactionCase -class TestBaseUserRoleHistory(SavepointCase): +class TestBaseUserRoleHistory(TransactionCase): @classmethod def setUpClass(cls): super(TestBaseUserRoleHistory, cls).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"]