changeset a349d95f5803 in modules/authentication_sms:5.0 details: https://hg.tryton.org/modules/authentication_sms?cmd=changeset;node=a349d95f5803 description: Show password field if password_sms is an authentication method
issue9255 review289921108 (grafted from 7fca1baab0c0f8181d12e2f93091a6088f97bfbe) diffstat: res.py | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diffs (29 lines): diff -r e986f05d269b -r a349d95f5803 res.py --- a/res.py Sat Apr 04 17:50:50 2020 +0200 +++ b/res.py Sat Apr 25 09:44:32 2020 +0200 @@ -8,10 +8,13 @@ from trytond.exceptions import LoginException from trytond.model import ModelSQL, fields from trytond.pool import PoolMeta, Pool +from trytond.pyson import Eval from trytond.tools import resolve __all__ = ['User', 'SMSCode'] logger = logging.getLogger(__name__) +_has_password_sms = 'password_sms' in config.get( + 'session', 'authentications', default='password').split(',') def send_sms(text, to): @@ -33,6 +36,11 @@ def __setup__(cls): super(User, cls).__setup__() cls._preferences_fields.append('mobile') + cls._buttons['reset_password']['invisible'] &= ( + ~Eval('email', True) | (not _has_password_sms)) + cls.password.states['invisible'] &= not _has_password_sms + cls.password_reset.states['invisible'] &= not _has_password_sms + cls.password_reset_expire.states['invisible'] &= not _has_password_sms @classmethod def _login_sms(cls, login, parameters):