[FIX] auth_totp_mail_enforce: cannot save option

Current behaviour:
When checking "All users" then saving,
it unchecks it then checks "Employees only"

Steps to reproduce:
1. Install auth_totp_mail_enforce
2. Go to Settings
3. Check "Two-factor authentication enforcing policy"
4. Hit Save
5. ("Employees only" is selected)
6. Select "All users"
7. Hit Save
8. ("Employees only" is still selected)

Cause of the issue:
Because of onchange, _onchange_auth_totp_enforce is
called when refreshing the page, which causes
auth_totp_policy to default as 'employee_required'

opw-3523880

closes odoo/odoo#139535

X-original-commit: 1d8423e397e7646eec9eebab8a1fd40e39605404
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Antoine Demany (ande) <ande@odoo.com>
This commit is contained in:
Antoine (ande)
2023-10-24 15:23:26 +00:00
parent 0a21137baa
commit cd1ddc7cad
@@ -21,7 +21,7 @@ class ResConfigSettings(models.TransientModel):
@api.onchange('auth_totp_enforce')
def _onchange_auth_totp_enforce(self):
if self.auth_totp_enforce:
self.auth_totp_policy = 'employee_required'
self.auth_totp_policy = self.auth_totp_policy or 'employee_required'
else:
self.auth_totp_policy = False