From 91f2dc1e13dff0185e83ca702782a168478b6f03 Mon Sep 17 00:00:00 2001 From: "Mohamed M. Hagag" Date: Sun, 22 Apr 2018 04:35:50 +0200 Subject: [PATCH 1/5] [10] auth_admin_passkey Fix Issue #1227 this is a fix for https://github.com/OCA/server-tools/issues/1227 based on the missing PR by akretion for 8 and 9 . https://github.com/OCA/server-tools/pull/519 --- auth_admin_passkey/models/res_config.py | 64 +++++++++++-------------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/auth_admin_passkey/models/res_config.py b/auth_admin_passkey/models/res_config.py index 06aed172f5d..3fef2b9859c 100644 --- a/auth_admin_passkey/models/res_config.py +++ b/auth_admin_passkey/models/res_config.py @@ -4,55 +4,49 @@ # 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") } + @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 '') + @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") } - 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 '') - 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, OpenERP 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, OpenERP will send an email """ + """to the account user.""") From 9f60d1250a2fa9cf4314b8ea90de092834608baf Mon Sep 17 00:00:00 2001 From: "Mohamed M. Hagag" Date: Sun, 22 Apr 2018 05:31:36 +0200 Subject: [PATCH 2/5] set 'False' instead of empty string avoid server errors if empty value for config params. --- auth_admin_passkey/models/res_config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auth_admin_passkey/models/res_config.py b/auth_admin_passkey/models/res_config.py index 3fef2b9859c..5255420afc0 100644 --- a/auth_admin_passkey/models/res_config.py +++ b/auth_admin_passkey/models/res_config.py @@ -22,7 +22,7 @@ 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 '') + config.auth_admin_passkey_send_to_admin or 'False') @api.model def get_default_auth_admin_passkey_send_to_user(self, fields): @@ -37,7 +37,7 @@ def set_auth_admin_passkey_send_to_user(self): 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 '') + config.auth_admin_passkey_send_to_user or 'False') auth_admin_passkey_send_to_admin = fields.Boolean( string='Send email to admin user.', From abe65efaabeba4a27a402108fea1e3bc44e3d665 Mon Sep 17 00:00:00 2001 From: "Mohamed M. Hagag" Date: Sun, 22 Apr 2018 06:10:11 +0200 Subject: [PATCH 3/5] fix for getting current value fix for getting current value I'm sure there can be a better way to get them. --- auth_admin_passkey/models/res_config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/auth_admin_passkey/models/res_config.py b/auth_admin_passkey/models/res_config.py index 5255420afc0..1e06723d562 100644 --- a/auth_admin_passkey/models/res_config.py +++ b/auth_admin_passkey/models/res_config.py @@ -14,7 +14,7 @@ def get_default_auth_admin_passkey_send_to_admin(self, fields): return { 'auth_admin_passkey_send_to_admin': self.env["ir.config_parameter"].get_param( - "auth_admin_passkey.send_to_admin") + "auth_admin_passkey.send_to_admin") in ['True','1'] and 1 or 0 } @api.multi @@ -29,7 +29,7 @@ def get_default_auth_admin_passkey_send_to_user(self, fields): return { 'auth_admin_passkey_send_to_user': self.env["ir.config_parameter"].get_param( - "auth_admin_passkey.send_to_user") + "auth_admin_passkey.send_to_user") in ['True','1'] and 1 or 0 } @api.multi @@ -42,11 +42,11 @@ def set_auth_admin_passkey_send_to_user(self): 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, OpenERP will send an email """ + """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, OpenERP will send an email """ + """with a different account, System will send an email """ """to the account user.""") From 31783cdc89483ed778c8777db35f36c346449946 Mon Sep 17 00:00:00 2001 From: "Mohamed M. Hagag" Date: Mon, 23 Apr 2018 10:58:51 +0200 Subject: [PATCH 4/5] update version number --- auth_admin_passkey/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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', From 598c76c0d55351d500590c89351ba8aa5ff2f7f1 Mon Sep 17 00:00:00 2001 From: "Mohamed M. Hagag" Date: Mon, 23 Apr 2018 11:03:12 +0200 Subject: [PATCH 5/5] Fix Lint checks --- auth_admin_passkey/models/res_config.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/auth_admin_passkey/models/res_config.py b/auth_admin_passkey/models/res_config.py index 1e06723d562..da79999b01b 100644 --- a/auth_admin_passkey/models/res_config.py +++ b/auth_admin_passkey/models/res_config.py @@ -5,6 +5,7 @@ from odoo import api, fields, models + class BaseConfigSettings(models.TransientModel): _inherit = 'base.config.settings' @@ -14,7 +15,7 @@ def get_default_auth_admin_passkey_send_to_admin(self, fields): return { '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 + "auth_admin_passkey.send_to_admin") in ['True', '1'] and 1 or 0 } @api.multi @@ -29,7 +30,7 @@ def get_default_auth_admin_passkey_send_to_user(self, fields): return { '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_user") in ['True', '1'] and 1 or 0 } @api.multi