Files
odoo_source/addons/auth_signup/models/base_config_settings.py
T
Denis Vermylen 689d6d6829 [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.
2017-07-06 12:53:39 +02:00

44 lines
2.0 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
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.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
# the value of the parameter is a nonempty string
res.update(
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
@api.multi
def set_values(self):
super(BaseConfigSettings, self).set_values()
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 == 'b2c'))
set_param('auth_signup.template_user_id', repr(self.auth_signup_template_user_id.id))
@api.multi
def open_template_user(self):
action = self.env.ref('base.action_res_users').read()[0]
action['res_id'] = self.env.ref('auth_signup.default_template_user').id
action['views'] = [[self.env.ref('base.view_users_form').id, 'form']]
return action