Configuration
This article contains the description of the appsettings.json configuration file. In this article, we will explain what settings are available in this file, what they are used for, and how to use these settings to change the functionality/behavior of Odoo API.
Making incorrect changes to the appsettings.json configuration file can lead to unexpected behaviour or malfunction.
The appsettings.json file overview
If you have worked on ASP.NET Core projects previously or you are familiar with ASP.NET then you might have used appsettings.json files before and have some understanding of what this file is and what this file is used for.
The JSON Schema defines the allowable properties for each application configuration setting.
{
"Connection": {
"Profiles": {
"<Connection Profile Name>": {
"ServerUrl": "<Odoo FQDN>",
"Database": "<Odoo Database>",
"Username": "<Odoo Username>",
"Password": "<Odoo Password or API Key>",
}
},
"Options": {
"ImmediateLogin": true,
"ServerCertificateValidation": true,
"TimeOut": 100000,
"UserAgent": "PsaTools.OdooXmlRpc/1.0.0.0",
"EnableCompression": true
}
},
"Export": {
"Profiles": {
"Countries ilike a and id greater or equal to 1": {
"Model": "res.country",
"Filter": [
[
">=",
"id",
"1"
],
[
"ilike",
"name",
"a"
]
],
"Fields": [
"name",
"code",
"currency_id"
],
"Order": "",
],
},
},
"Options": {
"Limit": 0,
"Offset": 0,
"AutoStart": false,
"Path": "C:\\Users\\%USERNAME%\\Downloads\\Export",
"File": "%zzz%_%yyyy%-%MM%-%dd%_%HH%-%mm%-%ss%_%model%.csv",
"OverWrite": false,
"Delimiter": ";",
"Format": 0,
"Compress": true
}
}
}
Settings available in the appsettings.json file
Connection
The connection profiles and connection options to an Odoo XML-RPC server are configured through this section.
Connection:Profiles:<Name>
ServerUrl
This setting expects a string value. Here you need to add the Odoo XML-RPC endpoint. Typically this is the URL used to access the Odoo instance.Database
This setting expects a string value. The Odoo database to connect to.Username
This setting expects a string value. The username to connect to the Odoo databasePassword
This setting expects a string value. The password or API key to connect to the Odoo database. More information how to create API keys can be found on the Odoo developer documentation here.- (Optional)
ImmediateLogin
If configured, overrides the value set in the connection options. See the Connection:Options section below for more information. - (Optional)
ServerCertificateValidation
If configured, overrides the value set in the connection options. See the Connection:Options section below for more information. - (Optional)
TimeOut
If configured, overrides the value set in the connection options. See the Connection:Options section below for more information. - (Optional)
UserAgent
If configured, overrides the value set in the connection options. See the Connection:Options section below for more information. - (Optional)
EnableCompression
If configured, overrides the value set in the connection options. See the Connection:Options section below for more information.
Connection:Options
- (Optional)
ImmediateLogin
This setting expects a boolean value. Set the value to true or false based on whether a login should be processed immediately after the connection profile is loaded. The default value is true. - (Optional)
ServerCertificateValidation
This setting expects a boolean value. Set the value to true or false based on whether the server certificate should be validated. When the value is set to false, any certificate will pass validation. The default value is true. - (Optional)
TimeOut
This setting expects an integer value. The Timeout property indicates the length of time, in milliseconds, until the Odoo XML-RPC request times out. The default value is 100000. - (Optional)
UserAgent
This setting expects a string value. The User-Agent request header string that is send to the Odoo XML-RPC server to identify this application. The default value is "PsaTools.OdooXmlRpc/[Version]" where [version] is the current version of the OdooXmlRpc Build. - (Optional)
EnableCompression
This setting expects a boolean value. When set to true, enables the client to take advantage of RPC compression. If enabled, responses will be transparently compressed, but only when the XML-RPC server declares its support for compression in the HTTP headers of the request.
Export
The export profiles and export options are configured through this section.
Export:Profiles:<Name>
-
Model
This setting expects a string value. Set the model for which data needs to be exported. -
(Optional)
Filter/Domain
This setting expects a array of arrays containing string values. Specify the search domain(s) to be applied when exporting data. Omit the setting or use an empty list to match all records. -
(Optional)
Fields
This setting expects a array of string values. Specify the model fields for which data needs to be exported. Omit the setting or use an empty list to select all model fields. -
(Optional)
Order
This setting expects a string value. The sort string used when exporting data. Omit the setting or leave blank to use the default sort order of the model. -
(Optional)
Limit
If configured, overrides the value set in the export options. See the Export:Options section below for more information. -
(Optional)
Offset
If configured, overrides the value set in the export options. See the Export:Options section below for more information. -
(Optional)
AutoStart
If configured, overrides the value set in the export options. See the Export:Options section below for more information. -
(Optional)
Path
If configured, overrides the value set in the export options. See the Export:Options section below for more information. -
(Optional)
File
If configured, overrides the value set in the export options. See the Export:Options section below for more information. -
(Optional)
OverWrite
If configured, overrides the value set in the export options. See the Export:Options section below for more information. -
(Optional)
Delimiter
If configured, overrides the value set in the export options. See the Export:Options section below for more information. -
(Optional)
Format
If configured, overrides the value set in the export options. See the Export:Options section below for more information. -
(Optional)
Compress
If configured, overrides the value set in the export options. See the Export:Options section below for more information.
Export:Options
- (Optional)
Limit
This setting expects an integer value. Set the maximum number of records to be returned. The default value is 0 (=all). - (Optional)
Offset
This setting expects an integer value. Set the number of results to ignore. The default value is 0 (=none). - (Optional)
AutoStart
This setting expects a boolean value. Set the value to true or false based on whether the export profile should be executed if Odoo API is running in batch mode. The default value is false. - (Optional)
Path
This setting expects a string value. Specifies the default path to be used when exporting data. The default value is an empty string. If no value is set or if the value set is not a valid path, OdooXmlRpc will use a predefined path based on the operating system Odoo API is being executed. The default values per operating system are: Windows: executing user's download folder, Linux: executing user's home folder, macOS: executing user's download folder. - (Optional)
File
This setting expects a string value. Specifies the default filename to be used when exporting data. The default value is an empty string. If no value is set or if the value set is not a valid file, Odoo API will use the model name. - (Optional)
OverWrite
This setting expects a boolean value. Set the value to true or false based on whether Odoo API is allowed to overwrite files. - (Optional)
Delimiter
This setting expects a string value. Specifies the delimiter (a sequence of one or more characters) to be used to export data to CSV format. The default value is a semicolon ";". - (Optional)
Format
This setting expects a string value. Specifies export format to be used when exporting data. Supported export formats are CSV and XLSX. The default value is "CSV". - (Optional)
Compress
This setting expects a boolean value. Set the value to true or false based on whether Odoo API should compress (zip format) the exported file.