diff --git a/auth_admin_passkey/__manifest__.py b/auth_admin_passkey/__manifest__.py index d42e5171fbc..92b9974a5fc 100644 --- a/auth_admin_passkey/__manifest__.py +++ b/auth_admin_passkey/__manifest__.py @@ -5,7 +5,7 @@ { 'name': 'Authentification - Admin Passkey', - 'version': '10.0.1.0.0', + 'version': '10.0.1.0.1', 'category': 'base', 'author': "GRAP,Odoo Community Association (OCA)", 'website': 'http://www.grap.coop', diff --git a/auth_admin_passkey/models/res_config.py b/auth_admin_passkey/models/res_config.py index 06aed172f5d..da79999b01b 100644 --- a/auth_admin_passkey/models/res_config.py +++ b/auth_admin_passkey/models/res_config.py @@ -4,55 +4,50 @@ # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from odoo import api, fields, models -from odoo.tools import safe_eval class BaseConfigSettings(models.TransientModel): _inherit = 'base.config.settings' + # Getter / Setter Section @api.model def get_default_auth_admin_passkey_send_to_admin(self, fields): - icp = self.env['ir.config_parameter'] return { - 'auth_admin_passkey_send_to_admin': safe_eval(icp.get_param( - 'auth_admin_passkey.send_to_admin', 'True')), + 'auth_admin_passkey_send_to_admin': + self.env["ir.config_parameter"].get_param( + "auth_admin_passkey.send_to_admin") in ['True', '1'] and 1 or 0 } + @api.multi + def set_auth_admin_passkey_send_to_admin(self): + for config in self: + self.env['ir.config_parameter'].set_param( + "auth_admin_passkey.send_to_admin", + config.auth_admin_passkey_send_to_admin or 'False') + @api.model def get_default_auth_admin_passkey_send_to_user(self, fields): - icp = self.env['ir.config_parameter'] return { - 'auth_admin_passkey_send_to_user': safe_eval(icp.get_param( - 'auth_admin_passkey.send_to_user', 'True')), + 'auth_admin_passkey_send_to_user': + self.env["ir.config_parameter"].get_param( + "auth_admin_passkey.send_to_user") in ['True', '1'] and 1 or 0 } - auth_admin_passkey_send_to_admin = fields.Boolean( - 'Send email to admin user.', - help=('When the administrator use his password to login in ' - 'with a different account, Odoo will send an email ' - 'to the admin user.'), - ) - auth_admin_passkey_send_to_user = fields.Boolean( - string='Send email to user.', - help=('When the administrator use his password to login in ' - 'with a different account, Odoo will send an email ' - 'to the account user.'), - ) - - @api.multi - def set_auth_admin_passkey_send_to_admin(self): - self.ensure_one() - - icp = self.env['ir.config_parameter'] - icp.set_param( - 'auth_admin_passkey.send_to_admin', - repr(self.auth_admin_passkey_send_to_admin)) - @api.multi def set_auth_admin_passkey_send_to_user(self): - self.ensure_one() + for config in self: + self.env['ir.config_parameter'].set_param( + "auth_admin_passkey.send_to_user", + config.auth_admin_passkey_send_to_user or 'False') - icp = self.env['ir.config_parameter'] - icp.set_param( - 'auth_admin_passkey.send_to_user', - repr(self.auth_admin_passkey_send_to_user)) + auth_admin_passkey_send_to_admin = fields.Boolean( + string='Send email to admin user.', + help="""When the administrator use his password to login in """ + """with a different account, System will send an email """ + """to the admin user.""") + + auth_admin_passkey_send_to_user = fields.Boolean( + string='Send email to user.', + help="""When the administrator use his password to login in """ + """with a different account, System will send an email """ + """to the account user.""")