Files
test/password_security/models/res_company.py
qihao.gong@jikimo.com 5e8e380a8e 密码模块修改
2023-07-13 17:31:16 +08:00

61 lines
1.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Copyright 2016 LasLabs Inc.
# Copyright 2017 Kaushal Prajapati <kbprajapati@live.com>.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
class ResCompany(models.Model):
_inherit = "res.company"
password_expiration = fields.Integer(
default=60,
help="密码过期前多少天",
string='密码过期天数'
)
password_length = fields.Integer(
default=12,
help="最小字符数",
string='密码最低长度'
)
password_lower = fields.Integer(
default=1,
help="需要小写字母数",
string='密码中包含小写字母数(最少)'
)
password_upper = fields.Integer(
default=1,
string='密码中包含大写字母数(最少)'
)
password_numeric = fields.Integer(
default=1,
help="需要数字位数",
string='密码中包含数字(最少)'
)
password_special = fields.Integer(
default=1,
help="需要唯一特殊字符的数量",
string='密码中包含特殊字符(最少)'
)
password_estimate = fields.Integer(
default=3,
help="强度估计所需的分数。介于0和4之间",
string='密码强度等级'
)
password_history = fields.Integer(
default=30,
help="禁止重复使用这许多以前的密码 - 使用负数字表示无限,或 0 表示禁用",
string='禁止重复使用这许多以前的密码-使用负数字表示无限或0表示禁用'
)
password_minimum = fields.Integer(
default=24,
help="用户再次更改密码之前的小时数",
string='更改密码间隔时长(小时)'
)
@api.constrains("password_estimate")
def _check_password_estimate(self):
if 0 > self.password_estimate > 4:
raise ValidationError(_("估计值必须介于 0 和 4 之间"))