diff --git a/password_security/models/res_users.py b/password_security/models/res_users.py index 8ee63b5aca..9d94940c80 100644 --- a/password_security/models/res_users.py +++ b/password_security/models/res_users.py @@ -78,7 +78,6 @@ def _check_password_policy(self, passwords): return result def password_match_message(self): - self.ensure_one() message = [] pwd_params = self._get_all_password_params() if pwd_params["lower"]: @@ -113,7 +112,6 @@ def _check_password(self, password): return True def _check_password_rules(self, password): - self.ensure_one() if not password: return True pwd_params = self._get_all_password_params() diff --git a/password_security/tests/test_change_password.py b/password_security/tests/test_change_password.py index 63f4f5f650..4934c736f8 100644 --- a/password_security/tests/test_change_password.py +++ b/password_security/tests/test_change_password.py @@ -1,6 +1,6 @@ # Copyright 2023 Onestein () # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). - +import re from unittest import mock from odoo import http @@ -134,3 +134,14 @@ def test_04_change_password_check_password_history(self): # Log in with new password: ensure we end up on the right page res_login2 = self.login("admin", "!asdQWE12345_4") self.assertEqual(res_login2.request.path_url, "/odoo") + + def test_20_write_password(self): + """Detects expected singleton errors writing passwords for more than one user""" + users = self.env["res.users"].search([], limit=2) + self.assertEqual(len(users), 2) + res = users.write({"password": "!asdQWE12345"}) + self.assertTrue(res) + + msg = re.escape(users[0].password_match_message()) + with self.assertRaisesRegex(ValidationError, msg): + users.write({"password": "12345678"})