From 689d6d68296ea32c2155dc1a61b593754ca3b968 Mon Sep 17 00:00:00 2001 From: Denis Vermylen Date: Fri, 12 May 2017 18:40:14 +0200 Subject: [PATCH] [IMP] website: add signup option in website settings This commit duplicates the General settings' User Signup options in the Website configuration, with a clear description of the options. We also remove the unnecessary usage of safe_eval in auth_signup's res_config.py. As stored values are repr values of a boolean field just comparing the string values is sufficient. There is no need to use safe_eval as it should be used only when necessary. --- .../models/base_config_settings.py | 17 +++++++------ .../views/base_config_settings_views.xml | 10 +++++--- .../website/models/website_config_settings.py | 25 ++++++++++++------- .../views/website_config_settings_views.xml | 13 ++++++++++ 4 files changed, 45 insertions(+), 20 deletions(-) diff --git a/addons/auth_signup/models/base_config_settings.py b/addons/auth_signup/models/base_config_settings.py index eb830c24e37..8ea0a8f2041 100644 --- a/addons/auth_signup/models/base_config_settings.py +++ b/addons/auth_signup/models/base_config_settings.py @@ -2,24 +2,27 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import api, fields, models -from odoo.tools.safe_eval import safe_eval + class BaseConfigSettings(models.TransientModel): _inherit = 'base.config.settings' auth_signup_reset_password = fields.Boolean(string='Enable password reset from Login page') - auth_signup_uninvited = fields.Boolean(string='Allow external users to sign up') + auth_signup_uninvited = fields.Selection([ + ('b2b', 'On invitation (B2B)'), + ('b2c', 'Free sign up (B2C)'), + ], string='Customer Account') auth_signup_template_user_id = fields.Many2one('res.users', string='Template user for new users created through signup') @api.model def get_values(self): res = super(BaseConfigSettings, self).get_values() get_param = self.env['ir.config_parameter'].sudo().get_param - # we use safe_eval on the result, since the value of the parameter is a nonempty string + # the value of the parameter is a nonempty string res.update( - auth_signup_reset_password=safe_eval(get_param('auth_signup.reset_password', 'False')), - auth_signup_uninvited=safe_eval(get_param('auth_signup.allow_uninvited', 'False')), - auth_signup_template_user_id=safe_eval(get_param('auth_signup.template_user_id', 'False')), + auth_signup_reset_password=get_param('auth_signup.reset_password', 'False').lower() == 'true', + auth_signup_uninvited='b2c' if get_param('auth_signup.allow_uninvited', 'False').lower() == 'true' else 'b2b', + auth_signup_template_user_id=get_param('auth_signup.template_user_id', 'False').lower() == 'true', ) return res @@ -29,7 +32,7 @@ class BaseConfigSettings(models.TransientModel): set_param = self.env['ir.config_parameter'].sudo().set_param # we store the repr of the values, since the value of the parameter is a required string set_param('auth_signup.reset_password', repr(self.auth_signup_reset_password)) - set_param('auth_signup.allow_uninvited', repr(self.auth_signup_uninvited)) + set_param('auth_signup.allow_uninvited', repr(self.auth_signup_uninvited == 'b2c')) set_param('auth_signup.template_user_id', repr(self.auth_signup_template_user_id.id)) @api.multi diff --git a/addons/auth_signup/views/base_config_settings_views.xml b/addons/auth_signup/views/base_config_settings_views.xml index 23c2b1f7608..aaae5a8ea22 100644 --- a/addons/auth_signup/views/base_config_settings_views.xml +++ b/addons/auth_signup/views/base_config_settings_views.xml @@ -9,14 +9,16 @@
-
-
+
+
+
+
+
+

Social Media