Source code for odoo_xmlrpc_twisted.functions.test_activatetoken
"""Test if a user with the "x_activate_token" does exist."""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]deftest_activatetoken(activate_token):""" Test if a user with the "x_activate_token" does exist. Gives back as the result true or false. """# get the actual date and timenow=datetime.now()custom_actual_date=now.strftime("%Y-%m-%d %H:%M:%S")result='False'ifactivate_token!='':# check over the users if a valid token does existnumber=models.execute_kw(db,uid,password,'res.users','search_count',[[['x_activate_token','=',activate_token],['x_activate_complete','=',False],['x_activate_date','>',custom_actual_date],]])ifnumber>0:result='True'return(result)