Python 在条件odoo 10下自动注销
我有一个问题,当我试图在奥多10自动注销。我创建了更改密码页面,更改密码后,我想结束会话并再次返回登录页面。但结果并没有让我进入登录页面。这是我的代码:Python 在条件odoo 10下自动注销,python,session,odoo-10,Python,Session,Odoo 10,我有一个问题,当我试图在奥多10自动注销。我创建了更改密码页面,更改密码后,我想结束会话并再次返回登录页面。但结果并没有让我进入登录页面。这是我的代码: @api.model def create(self, vals): res = super(MyPass, self).create(vals) get_new_passwd = vals['new_password'] get_conf_passwd = vals['confirm_pwd'] if ge
@api.model
def create(self, vals):
res = super(MyPass, self).create(vals)
get_new_passwd = vals['new_password']
get_conf_passwd = vals['confirm_pwd']
if get_conf_passwd != get_new_passwd:
raise ValidationError ("Pass")
hashing_pass = CryptContext(['pbkdf2_sha512']).encrypt(get_new_passwd)
data_users = self.env['res.users'].browse(self.env.uid)
data_users.write({'password_crypt': hashing_pass})
request.session.logout(keep_db=True
我找到了解决办法
def check(self, **kw):
get_re_users = request.env.user
error = {}
if get_re_users.passwd_changed:
return werkzeug.utils.redirect('/web')
else:
if request.httprequest.method == 'POST':
get_new_passwd = http.request.params['new_password']
get_conf_passwd = http.request.params['confirm_pwd']
session = http.request.session
hashing_pass = CryptContext(['pbkdf2_sha512']).encrypt(get_new_passwd)
data_users = http.request.env['res.users'].sudo().browse(http.request.env.uid)
data_users.write({'password_crypt': hashing_pass, "passwd_changed":True, "name":get_username_odoo, "login":get_name_login})
if session.db and session.uid:
session.logout(keep_db=True)
# return {
# 'type' : 'ir.actions.act_url',
# 'url': '/web',
# 'target': 'self',
# }
return werkzeug.utils.redirect('/web/login')
return http.request.render('name_model.id_view')
很好的尝试。如果你找到了解决方案,请发布it@Stefani@Naveen我找到答案,检查问题。我正在更新我的代码。