mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[MIG] base_user_role_history: Migration to 16.0
This commit is contained in:
@@ -14,16 +14,16 @@ Base User Role History
|
|||||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||||
:alt: License: AGPL-3
|
:alt: License: AGPL-3
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github
|
.. |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
|
:alt: OCA/server-backend
|
||||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
.. |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
|
:alt: Translate me on Weblate
|
||||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
.. |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
|
:alt: Try me on Runbot
|
||||||
|
|
||||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||||
|
|
||||||
This addon provides history for roles modifications on users.
|
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
|
Each time a role is added/updated/unlinked on a user, a new role history line
|
||||||
@@ -53,7 +53,7 @@ Bug Tracker
|
|||||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-backend/issues>`_.
|
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-backend/issues>`_.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
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
|
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||||
`feedback <https://github.com/OCA/server-backend/issues/new?body=module:%20base_user_role_history%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
`feedback <https://github.com/OCA/server-backend/issues/new?body=module:%20base_user_role_history%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||||
|
|
||||||
Do not contact contributors directly about support or help with technical issues.
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|
||||||
@@ -90,8 +90,8 @@ promote its widespread use.
|
|||||||
|
|
||||||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|
||||||
|
|
||||||
|maintainer-ThomasBinsfeld|
|
|maintainer-ThomasBinsfeld|
|
||||||
|
|
||||||
This module is part of the `OCA/server-backend <https://github.com/OCA/server-backend/tree/13.0/base_user_role_history>`_ project on GitHub.
|
This module is part of the `OCA/server-backend <https://github.com/OCA/server-backend/tree/16.0/base_user_role_history>`_ project on GitHub.
|
||||||
|
|
||||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"name": "Base User Role History",
|
"name": "Base User Role History",
|
||||||
"summary": """
|
"summary": """
|
||||||
This module allows to track the changes on users roles.""",
|
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",
|
"license": "AGPL-3",
|
||||||
"author": "ACSONE SA/NV, " "Odoo Community Association (OCA)",
|
"author": "ACSONE SA/NV, " "Odoo Community Association (OCA)",
|
||||||
"website": "https://github.com/OCA/server-backend",
|
"website": "https://github.com/OCA/server-backend",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Odoo Server 13.0\n"
|
"Project-Id-Version: Odoo Server 16.0\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"Last-Translator: \n"
|
"Last-Translator: \n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Odoo Server 13.0\n"
|
"Project-Id-Version: Odoo Server 16.0\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"PO-Revision-Date: 2021-03-16 18:45+0000\n"
|
"PO-Revision-Date: 2021-03-16 18:45+0000\n"
|
||||||
"Last-Translator: Ana Suárez <ana.suarez@qubiq.es>\n"
|
"Last-Translator: Ana Suárez <ana.suarez@qubiq.es>\n"
|
||||||
|
|||||||
@@ -114,5 +114,4 @@ class BaseUserRoleLineHistory(models.Model):
|
|||||||
)
|
)
|
||||||
# Create the history lines with sudo
|
# Create the history lines with sudo
|
||||||
# (nobody has the create right)
|
# (nobody has the create right)
|
||||||
for role_history_vals in role_history_line_vals_by_role_line.values():
|
self.sudo().create(list(role_history_line_vals_by_role_line.values()))
|
||||||
self.sudo().create(role_history_vals)
|
|
||||||
|
|||||||
@@ -34,26 +34,31 @@ class ResUsers(models.Model):
|
|||||||
@api.model_create_multi
|
@api.model_create_multi
|
||||||
def create(self, vals_list):
|
def create(self, vals_list):
|
||||||
res = super().create(vals_list)
|
res = super().create(vals_list)
|
||||||
for vals in vals_list:
|
if all("role_line_ids" not in vals for vals in vals_list):
|
||||||
if "role_line_ids" not in vals:
|
return res
|
||||||
return res
|
|
||||||
new_role_line_values_by_user = res._get_role_line_values_by_user()
|
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(
|
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
|
return res
|
||||||
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
if "role_line_ids" not in vals:
|
if "role_line_ids" not in vals:
|
||||||
return super().write(vals)
|
return super().write(vals)
|
||||||
old_role_line_values_by_user = self._get_role_line_values_by_user()
|
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)
|
res = super().write(vals)
|
||||||
new_role_line_values_by_user = self._get_role_line_values_by_user()
|
new_role_line_values_by_user = self._get_role_line_values_by_user()
|
||||||
self.env["base.user.role.line.history"].create_from_vals(
|
self.env["base.user.role.line.history"].create_from_vals(
|
||||||
old_role_line_values_by_user, new_role_line_values_by_user
|
old_role_line_values_by_user, new_role_line_values_by_user
|
||||||
)
|
)
|
||||||
self.write({"last_role_line_modification": fields.Datetime.now()})
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def show_role_lines_history(self): # pragma: no cover
|
def show_role_lines_history(self): # pragma: no cover
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ ul.auto-toc {
|
|||||||
!! This file is generated by oca-gen-addon-readme !!
|
!! This file is generated by oca-gen-addon-readme !!
|
||||||
!! changes will be overwritten. !!
|
!! changes will be overwritten. !!
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-backend/tree/13.0/base_user_role_history"><img alt="OCA/server-backend" src="https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-backend-13-0/server-backend-13-0-base_user_role_history"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/253/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-backend/tree/16.0/base_user_role_history"><img alt="OCA/server-backend" src="https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-backend-16-0/server-backend-16-0-base_user_role_history"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/253/16.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||||
<p>This addon provides history for roles modifications on users.
|
<p>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
|
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.
|
is created mentioning what changes were made and who made them.
|
||||||
@@ -401,7 +401,7 @@ a role deletion, module could be upgraded.</p>
|
|||||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-backend/issues">GitHub Issues</a>.
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-backend/issues">GitHub Issues</a>.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
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
|
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||||
<a class="reference external" href="https://github.com/OCA/server-backend/issues/new?body=module:%20base_user_role_history%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
<a class="reference external" href="https://github.com/OCA/server-backend/issues/new?body=module:%20base_user_role_history%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
@@ -428,7 +428,7 @@ mission is to support the collaborative development of Odoo features and
|
|||||||
promote its widespread use.</p>
|
promote its widespread use.</p>
|
||||||
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
|
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
|
||||||
<p><a class="reference external" href="https://github.com/ThomasBinsfeld"><img alt="ThomasBinsfeld" src="https://github.com/ThomasBinsfeld.png?size=40px" /></a></p>
|
<p><a class="reference external" href="https://github.com/ThomasBinsfeld"><img alt="ThomasBinsfeld" src="https://github.com/ThomasBinsfeld.png?size=40px" /></a></p>
|
||||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-backend/tree/13.0/base_user_role_history">OCA/server-backend</a> project on GitHub.</p>
|
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-backend/tree/16.0/base_user_role_history">OCA/server-backend</a> project on GitHub.</p>
|
||||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
|
|
||||||
from datetime import date, timedelta
|
from datetime import date, timedelta
|
||||||
|
|
||||||
from odoo.tests.common import SavepointCase
|
from odoo.tests.common import TransactionCase
|
||||||
|
|
||||||
|
|
||||||
class TestBaseUserRoleHistory(SavepointCase):
|
class TestBaseUserRoleHistory(TransactionCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super(TestBaseUserRoleHistory, cls).setUpClass()
|
super(TestBaseUserRoleHistory, cls).setUpClass()
|
||||||
|
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
|
||||||
# MODELS
|
# MODELS
|
||||||
|
|
||||||
cls.history_line_model = cls.env["base.user.role.line.history"]
|
cls.history_line_model = cls.env["base.user.role.line.history"]
|
||||||
|
|||||||
1
setup/base_user_role_history/odoo/addons/base_user_role_history
Symbolic link
1
setup/base_user_role_history/odoo/addons/base_user_role_history
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../../../base_user_role_history
|
||||||
6
setup/base_user_role_history/setup.py
Normal file
6
setup/base_user_role_history/setup.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user