Source code for odoo_xmlrpc_twisted.functions.update_resettoken

"""
Update the "x_reset_token" of a user.
"""


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 update_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 table now = datetime.now() actual_date = now.strftime("%Y-%m-%d %H:%M:%S") result = 'False' user_id = '' name = '' login = '' email = '' partner_id = '' if reset_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],]]) if list(res_users_id): for key, value in list(res_users_id[0].items()): if key == "id": user_id = value if key == "name": name = value if key == "login": login = value if key == "email": email = value if key == "partner_id": partner_id = value[0] # update the res_users record # so that the token could no longer be used models.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)