|
6 | 6 | class ResConfigSettings(models.TransientModel):
|
7 | 7 | _inherit = "res.config.settings"
|
8 | 8 |
|
| 9 | + # Imagine that the ir.config_parameter password_security.numeric has |
| 10 | + # a default value of 1. If the user sets the value to 0 on the config page, |
| 11 | + # the ir.config_parameter is deleted... but when the ir.config_parameter is not |
| 12 | + # present in the database, Odoo displays the default value |
| 13 | + # on the config page => Odoo displays 1 ! |
| 14 | + # So, when the users sets the value of 0 on the config page, he will see 1 |
| 15 | + # after saving the page !!! |
| 16 | + # If the default value is 0 (like auth_password_policy.minlength in the |
| 17 | + # module auth_password_policy of the official addons), there is no problem. |
| 18 | + # So the solution to avoid this problem and have a non-null default value: |
| 19 | + # 1) define the ir.config_parameter fields on res.config.settings with default=0 |
| 20 | + # 2) initialize the ir.config_parameter with a default value in the init script |
| 21 | + # So the default value of the fields below are written in post_install.py |
9 | 22 | password_expiration = fields.Integer(
|
10 |
| - related="company_id.password_expiration", readonly=False |
| 23 | + string="Days", |
| 24 | + default=0, |
| 25 | + config_parameter="password_security.expiration_days", |
| 26 | + help="How many days until passwords expire", |
11 | 27 | )
|
12 | 28 | password_minimum = fields.Integer(
|
13 |
| - related="company_id.password_minimum", readonly=False |
| 29 | + string="Minimum Hours", |
| 30 | + default=0, |
| 31 | + config_parameter="password_security.minimum_hours", |
| 32 | + help="Number of hours until a user may change password again", |
14 | 33 | )
|
15 | 34 | password_history = fields.Integer(
|
16 |
| - related="company_id.password_history", readonly=False |
| 35 | + string="History", |
| 36 | + default=0, |
| 37 | + config_parameter="password_security.history", |
| 38 | + help="Disallow reuse of this many previous passwords - use negative " |
| 39 | + "number for infinite, or 0 to disable", |
| 40 | + ) |
| 41 | + password_lower = fields.Integer( |
| 42 | + string="Lowercase", |
| 43 | + default=0, |
| 44 | + config_parameter="password_security.lower", |
| 45 | + help="Require number of lowercase letters", |
| 46 | + ) |
| 47 | + password_upper = fields.Integer( |
| 48 | + string="Uppercase", |
| 49 | + default=0, |
| 50 | + config_parameter="password_security.upper", |
| 51 | + help="Require number of uppercase letters", |
17 | 52 | )
|
18 |
| - password_lower = fields.Integer(related="company_id.password_lower", readonly=False) |
19 |
| - password_upper = fields.Integer(related="company_id.password_upper", readonly=False) |
20 | 53 | password_numeric = fields.Integer(
|
21 |
| - related="company_id.password_numeric", readonly=False |
| 54 | + string="Numeric", |
| 55 | + default=0, |
| 56 | + config_parameter="password_security.numeric", |
| 57 | + help="Require number of numeric digits", |
22 | 58 | )
|
23 | 59 | password_special = fields.Integer(
|
24 |
| - related="company_id.password_special", readonly=False |
| 60 | + string="Special", |
| 61 | + default=0, |
| 62 | + config_parameter="password_security.special", |
| 63 | + help="Require number of unique special characters", |
25 | 64 | )
|
0 commit comments