From da63b64389fcd7b598c4e1edd3814fda05116784 Mon Sep 17 00:00:00 2001
From: herqs
Date: Mon, 11 Apr 2022 11:47:35 +0300
Subject: [PATCH] [MIG] auth_user_case_insensitive: Migration to 15.0
---
auth_user_case_insensitive/README.rst | 10 ++---
auth_user_case_insensitive/__manifest__.py | 2 +-
auth_user_case_insensitive/hooks.py | 2 +-
auth_user_case_insensitive/i18n/lt.po | 37 +++++++++++++++++++
.../models/res_users.py | 6 +--
.../static/description/index.html | 6 +--
.../tests/test_res_users.py | 36 ++++++------------
.../odoo/addons/auth_user_case_insensitive | 1 +
setup/auth_user_case_insensitive/setup.py | 6 +++
9 files changed, 68 insertions(+), 38 deletions(-)
create mode 100644 auth_user_case_insensitive/i18n/lt.po
create mode 120000 setup/auth_user_case_insensitive/odoo/addons/auth_user_case_insensitive
create mode 100644 setup/auth_user_case_insensitive/setup.py
diff --git a/auth_user_case_insensitive/README.rst b/auth_user_case_insensitive/README.rst
index 0cb6aae9ac..4ec9fd25a4 100644
--- a/auth_user_case_insensitive/README.rst
+++ b/auth_user_case_insensitive/README.rst
@@ -14,13 +14,13 @@ Case Insensitive Logins
: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--auth-lightgray.png?logo=github
- :target: https://github.com/OCA/server-auth/tree/14.0/auth_user_case_insensitive
+ :target: https://github.com/OCA/server-auth/tree/15.0/auth_user_case_insensitive
:alt: OCA/server-auth
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/server-auth-14-0/server-auth-14-0-auth_user_case_insensitive
+ :target: https://translation.odoo-community.org/projects/server-auth-15-0/server-auth-15-0-auth_user_case_insensitive
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/251/14.0
+ :target: https://runbot.odoo-community.org/runbot/251/15.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -54,7 +54,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.
@@ -87,6 +87,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-This module is part of the `OCA/server-auth `_ project on GitHub.
+This module is part of the `OCA/server-auth `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/auth_user_case_insensitive/__manifest__.py b/auth_user_case_insensitive/__manifest__.py
index 00d1d4b864..2236d35f0a 100644
--- a/auth_user_case_insensitive/__manifest__.py
+++ b/auth_user_case_insensitive/__manifest__.py
@@ -4,7 +4,7 @@
{
"name": "Case Insensitive Logins",
"summary": "Makes the user login field case insensitive",
- "version": "14.0.1.0.0",
+ "version": "15.0.1.0.0",
"category": "Authentication",
"website": "https://github.com/OCA/server-auth",
"author": "LasLabs, Odoo Community Association (OCA)",
diff --git a/auth_user_case_insensitive/hooks.py b/auth_user_case_insensitive/hooks.py
index c6f43236d4..50a54b7951 100644
--- a/auth_user_case_insensitive/hooks.py
+++ b/auth_user_case_insensitive/hooks.py
@@ -21,7 +21,7 @@ def pre_init_hook_login_check(cr):
users.append(login)
else:
raise ValidationError(
- _("Conflicting user logins exist for `%s`" % login)
+ _("Conflicting user logins exist for `%s`", login)
)
diff --git a/auth_user_case_insensitive/i18n/lt.po b/auth_user_case_insensitive/i18n/lt.po
new file mode 100644
index 0000000000..94c9e66bfa
--- /dev/null
+++ b/auth_user_case_insensitive/i18n/lt.po
@@ -0,0 +1,37 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * auth_user_case_insensitive
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 15.0+e\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2022-04-07 08:58+0000\n"
+"PO-Revision-Date: 2022-04-07 08:58+0000\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: auth_user_case_insensitive
+#: code:addons/auth_user_case_insensitive/hooks.py:0
+#, python-format
+msgid "Conflicting user logins exist for `%s`"
+msgstr "Egzistuoja keli vartotojai su prisijungimu `%s`"
+
+#. module: auth_user_case_insensitive
+#: model:ir.model.fields,field_description:auth_user_case_insensitive.field_res_users__login
+msgid "Login"
+msgstr "Prisijungimas"
+
+#. module: auth_user_case_insensitive
+#: model:ir.model.fields,help:auth_user_case_insensitive.field_res_users__login
+msgid "Used to log into the system. Case insensitive."
+msgstr "Naudojamas prisijungti į sistemą. Raidžių dydis nesvarbus."
+
+#. module: auth_user_case_insensitive
+#: model:ir.model,name:auth_user_case_insensitive.model_res_users
+msgid "Users"
+msgstr "Vartotojai"
diff --git a/auth_user_case_insensitive/models/res_users.py b/auth_user_case_insensitive/models/res_users.py
index 1d0569cb26..50a8cb11e1 100644
--- a/auth_user_case_insensitive/models/res_users.py
+++ b/auth_user_case_insensitive/models/res_users.py
@@ -14,7 +14,7 @@ class ResUsers(models.Model):
@classmethod
def _login(cls, db, login, password, user_agent_env):
"""Overload _login to lowercase the `login` before passing to the
- super"""
+ super."""
login = login.lower()
return super(ResUsers, cls)._login(
db, login, password, user_agent_env=user_agent_env
@@ -22,13 +22,13 @@ def _login(cls, db, login, password, user_agent_env):
@api.model_create_multi
def create(self, vals_list):
- """ Overload create multiple to lowercase login """
+ """Overload create multiple to lowercase login."""
for val in vals_list:
val["login"] = val.get("login", "").lower()
return super(ResUsers, self).create(vals_list)
def write(self, vals):
- """ Overload write to lowercase login """
+ """Overload write to lowercase login."""
if vals.get("login"):
vals["login"] = vals["login"].lower()
return super(ResUsers, self).write(vals)
diff --git a/auth_user_case_insensitive/static/description/index.html b/auth_user_case_insensitive/static/description/index.html
index 767e81c075..eb99bc2a52 100644
--- a/auth_user_case_insensitive/static/description/index.html
+++ b/auth_user_case_insensitive/static/description/index.html
@@ -367,7 +367,7 @@ Case Insensitive Logins
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
This module makes user logins case insensitive. It also overwrites the
search method to allow these case insensitive logins to work on a database
that previously had case sensitive logins.
@@ -399,7 +399,7 @@
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.
@@ -426,7 +426,7 @@
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-
This module is part of the OCA/server-auth project on GitHub.
+
This module is part of the OCA/server-auth project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/auth_user_case_insensitive/tests/test_res_users.py b/auth_user_case_insensitive/tests/test_res_users.py
index c18741b4ce..f09abb57bf 100644
--- a/auth_user_case_insensitive/tests/test_res_users.py
+++ b/auth_user_case_insensitive/tests/test_res_users.py
@@ -2,9 +2,7 @@
# Copyright 2021 Open Source Integrators
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
-from odoo import api, registry
from odoo.tests.common import TransactionCase
-from odoo.tools import mute_logger
class TestResUsers(TransactionCase):
@@ -20,13 +18,13 @@ def setUp(self):
self.model_obj = self.env["res.users"]
def _new_record(self):
- """ It should enerate a new record to test with """
+ """Gnerate a new record to test with."""
partner_id = self.env["res.partner"].create(self.partner_vals)
self.vals["partner_id"] = partner_id.id
return self.model_obj.create(self.vals)
def test_login_is_lowercased_on_create(self):
- """ It should verify the login is set to lowercase on create """
+ """Verify the login is set to lowercase on create."""
rec_id = self._new_record()
self.assertEqual(
self.login.lower(),
@@ -35,7 +33,7 @@ def test_login_is_lowercased_on_create(self):
)
def test_login_is_lowercased_on_write(self):
- """ It should verify the login is set to lowercase on write """
+ """Verify the login is set to lowercase on write."""
rec_id = self._new_record()
rec_id.write({"login": self.login})
self.assertEqual(
@@ -45,26 +43,14 @@ def test_login_is_lowercased_on_write(self):
)
def test_login_login_is_lowercased(self):
- """ It should verify the login is set to lowercase on login """
- rec_id = self._new_record()
- # We have to commit this cursor, because `_login` uses a fresh cursor
- self.env.cr.commit()
- with mute_logger("odoo.addons.auth_ldap.models.res_company_ldap"):
- res_id = self.model_obj._login(
- self.env.registry.db_name,
- self.login.upper(),
- "password",
- {"interactive": True},
- )
- # Now clean up our mess to preserve idempotence
- with api.Environment.manage():
- with registry(self.env.registry.db_name).cursor() as new_cr:
- new_cr.execute(
- "DELETE FROM res_users WHERE \
- login='%s'"
- % self.login.lower()
- )
- new_cr.commit()
+ """verify the login is set to lowercase on login."""
+ rec_id = self.model_obj.search([("login", "=", "admin")])
+ res_id = self.model_obj._login(
+ self.env.registry.db_name,
+ "AdMiN",
+ "admin",
+ {"interactive": True},
+ )
self.assertEqual(
rec_id.id,
res_id,
diff --git a/setup/auth_user_case_insensitive/odoo/addons/auth_user_case_insensitive b/setup/auth_user_case_insensitive/odoo/addons/auth_user_case_insensitive
new file mode 120000
index 0000000000..8518faeb78
--- /dev/null
+++ b/setup/auth_user_case_insensitive/odoo/addons/auth_user_case_insensitive
@@ -0,0 +1 @@
+../../../../auth_user_case_insensitive
\ No newline at end of file
diff --git a/setup/auth_user_case_insensitive/setup.py b/setup/auth_user_case_insensitive/setup.py
new file mode 100644
index 0000000000..28c57bb640
--- /dev/null
+++ b/setup/auth_user_case_insensitive/setup.py
@@ -0,0 +1,6 @@
+import setuptools
+
+setuptools.setup(
+ setup_requires=['setuptools-odoo'],
+ odoo_addon=True,
+)