Ai
2 Star 0 Fork 0

oca-github/server-tools

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
hooks.py 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
# -*- coding: utf-8 -*-
# Copyright 2017 LasLabs Inc.
# 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(cr):
"""This hook will look to see if any conflicting logins exist before
the module is installed
:param openerp.sql_db.Cursor cr:
Database cursor.
"""
with cr.savepoint():
users = []
cr.execute("SELECT login FROM res_users")
for user in 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(cr, registry):
"""After the module is installed, set all logins to lowercase
:param openerp.sql_db.Cursor cr:
Database cursor.
:param openerp.modules.registry.RegistryManager registry:
Database registry, using v7 api.
"""
with cr.savepoint():
cr.execute("UPDATE res_users SET login=lower(login)")
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/oca-github/server-tools.git
git@gitee.com:oca-github/server-tools.git
oca-github
server-tools
server-tools
10.0

搜索帮助