Source code for django_webapps_fullstack.settings.get_settings_odoo
"""For the initialisation get dedicated valuesto log onto Odoo system."""importos.pathimportxmlrpc.clientasxmlrpclibimportconfigparser
[docs]defget_settings_odoo():""" For the initialisation get all the parameters from the parameter file "parameter_global.ini" to log into the Odoo system. The result of the function are the parameters to log onto the odoo system via "xmlrpclib". This function is used by all modules which communicate with the odoo system by "xmlrpclib" server functionality. """# get the location of the Settings File "parameter_global.ini"pathname=os.path.dirname(os.path.abspath(__file__))filename='parameter_global.ini'fullpath=os.path.join(pathname,filename)# create a configparser objectconfig=configparser.ConfigParser()# read the configuration file using configparser with UTF-8config.read(fullpath,encoding='utf-8')# get the values from the configuration file "parameter_global.ini"url=config['get_settings_odoo']['url']db=config['get_settings_odoo']['db']username=config['get_settings_odoo']['username']password=config['get_settings_odoo']['password']# set the parameter to log onto odoo systemcommon=xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(url))uid=common.authenticate(db,username,password,{})models=xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url))return(db,uid,username,password,models,common)