Source code for odoo_xmlrpc_twisted.support.support_update_activatetoken
"""Supporting program to test the module :func:`odoo_xmlrpc_twisted.functions.update_activatetoken`."""importsysimportosimportconfigparserfromdatetimeimportdatetime,timedelta# Add functions directory to path for importing custom modulessys.path.append(os.path.join(os.path.dirname(__file__),'..','functions'))fromupdate_activatetokenimportupdate_activatetokenfromget_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_activate_date=duration_date.strftime("%Y-%m-%d %H:%M:%S")
[docs]defsupport_update_activatetoken(custom_activate_token):""" Function to test the module "update_activatetoken". As a prerequisite, 'x_activate_complete' must be set to 'False', x_activate_token' must be set and also x_activate_date. Then the function 'update_activatetoken' will be called to see if it works. Result is 'True' or 'False'. """ifcustom_activate_token!='':# set the prerequites so that the call of 'update_activatetoken' should work models.execute_kw(db,uid,password,'res.users','write',[[custom_user_id],{'x_activate_token':custom_activate_token,'x_activate_complete':False,'x_activate_date':custom_activate_date,}])# call the function update_activatetoken to see if it worksresult=update_activatetoken(custom_activate_token)return(result)