Source code for odoo_xmlrpc_twisted.functions.test_activatetoken

"""
Test if a user with the "x_activate_token" does exist.
"""


from datetime import datetime


# 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_odoo import get_settings_odoo
except ImportError:
    from get_settings_odoo import get_settings_odoo
result   = get_settings_odoo()
db       = result[0]
uid      = result[1]
password = result[3]
models   = result[4]


[docs] def test_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 time now = datetime.now() custom_actual_date = now.strftime("%Y-%m-%d %H:%M:%S") result = 'False' if activate_token != '': # check over the users if a valid token does exist number = 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], ]]) if number > 0: result = 'True' return(result)