Source code for odoo_xmlrpc_twisted.functions.update_resettoken
"""Update the "x_reset_token" of a user."""fromdatetimeimportdatetime# call the function "get_settings_odoo" to get the parameters# for the logging of the model on the "odoo Webservice API"try:from.get_settings_odooimportget_settings_odooexceptImportError:fromget_settings_odooimportget_settings_odooresult=get_settings_odoo()db=result[0]uid=result[1]password=result[3]models=result[4]
[docs]defupdate_resettoken(reset_token):""" Update the "x_reset_token" of the user. After the update, the token could no longer be used. """# get the actual date and time for some values to store in the odoo database tablenow=datetime.now()actual_date=now.strftime("%Y-%m-%d %H:%M:%S")result='False'user_id=''name=''login=''email=''partner_id=''ifreset_token!='':# check over the nonactive users if a valid token does exist res_users_id=models.execute_kw(db,uid,password,'res.users','search_read',[[['x_reset_token','=',reset_token],['x_reset_complete','=',False],['x_reset_date','>',actual_date],['x_activate_complete','=',True],]])iflist(res_users_id):forkey,valueinlist(res_users_id[0].items()):ifkey=="id":user_id=valueifkey=="name":name=valueifkey=="login":login=valueifkey=="email":email=valueifkey=="partner_id":partner_id=value[0]# update the res_users record# so that the token could no longer be usedmodels.execute_kw(db,uid,password,'res.users','write',[[user_id],{'x_reset_complete':'True',}])result='True'return(result,user_id,name,login,email,partner_id)