Source code for odoo_xmlrpc_twisted.support.support_update_resettoken
"""Supporting program to test the module :func:`odoo_xmlrpc_twisted.functions.update_resettoken`."""importsysimportosimportconfigparserfromdatetimeimportdatetime,timedelta# Add functions directory to path for importing custom modulessys.path.append(os.path.join(os.path.dirname(__file__),'..','functions'))fromupdate_resettokenimportupdate_resettokenfromget_settings_odooimportget_settings_odoo# Call the function "get_settings_odoo" to get the parameters# for the logging of the model on the "odoo Webservice API"result=get_settings_odoo()db=result[0]uid=result[1]password=result[3]models=result[4]# ------- get parameter from the settings file "parameter_test.ini" # Name and full path of the "ini" file.# As the file "parameter_test.ini" is in the subdirectory "test"# set the path_name to that directory.filename="parameter_test.ini"current=os.path.dirname(os.path.realpath(__file__))parent_directory=os.path.dirname(current)path_name=parent_directory+'/config'fullpath=os.path.join(path_name,filename)config=configparser.ConfigParser()config.read(fullpath)# get the dedicated user_idcustom_user_id=int(config.get('get_settings_customer','user_id'))# set the max duration of the token# plus 1 day as to be on the safe side ...duration_date=datetime.now()+timedelta(days=1)custom_reset_date=duration_date.strftime("%Y-%m-%d %H:%M:%S")
[docs]defsupport_update_resettoken(custom_reset_token):""" Function to test the module "update_resettokenn". As a prerequisite, 'x_activate_complete' must be set to 'False', 'x_reset_complete' must be set to False, x_reset_token' must be set and also x_reset_date. Then the function 'update_resettoken' will be called to see if it works. Result is 'True' or 'False'. """ifcustom_reset_token!='':# set the prerequites so that the call of 'update_resettoken' should work models.execute_kw(db,uid,password,'res.users','write',[[custom_user_id],{'x_reset_token':custom_reset_token,'x_activate_complete':True,'x_reset_complete':False,'x_reset_date':custom_reset_date,}])# call the function update_resettoken to see if it worksresult=update_resettoken(custom_reset_token)return(result)