-
-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13f74eb
commit 15afd7b
Showing
3 changed files
with
38 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright 2017 LasLabs Inc. | ||
# Copyright 2021 Open Source Integrators | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from odoo import _ | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
def pre_init_hook_login_check(env): | ||
"""This hook will look to see if any conflicting logins exist before | ||
the module is installed | ||
:param env: | ||
Environment. | ||
""" | ||
with env.cr.savepoint(): | ||
users = [] | ||
env.cr.execute("SELECT login FROM res_users") | ||
for user in env.cr.fetchall(): | ||
login = user[0].lower() | ||
if login not in users: | ||
users.append(login) | ||
else: | ||
raise ValidationError( | ||
_("Conflicting user logins exist for `%s`", login) | ||
) | ||
|
||
|
||
def post_init_hook_login_convert(env): | ||
"""After the module is installed, set all logins to lowercase | ||
:param env: | ||
Environment. | ||
""" | ||
with env.cr.savepoint(): | ||
env.cr.execute("UPDATE res_users SET login=lower(login)") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters