YAML Format Specification
The YAML format mimics the Odoo database structure and data, providing a convenient way to export and import data to/from Odoo and store it in version control systems.
Please refer to the YAML Export/Import page for the information on how to export and import YAML files.
Each YAML file contains the following sections:
- Header
- Records
Below is an example of a YAML file which contains a Command record:
# This file is generated with Cetmix Tower.
# Details and documentation: https://cetmix.com/tower
# This is a command example
cetmix_tower_yaml_version: 1
records:
- cetmix_tower_model: command
access_level: manager
reference: add_user_to_docker_group
name: Add user to "docker" group
action: ssh_command
allow_parallel_run: false
note: Adds current user to "docker" group to allow running Docker commands without
'sudo'
tag_ids:
- reference: docker
name: Docker
color: 4
- reference: system
name: System
color: 1
path: false
code: |-
{% if tower.server.os == "Debian 11" %}
/usr/sbin/usermod -a -G docker {{ tower.server.username }}
{% else %}
usermod -a -G docker {{ tower.server.username }}
{% endif %}
server_status: false
Header
cetmix_tower_yaml_version
Type: Number
This is an optional field, used to identify the version of the YAML format. If the YAML file version is higher than the version supported by Cetmix Tower, an exception will be raised during import.
YAML file version
Current supported version is 1
records
YAML field type: List
A YAML file can contain multiple records, which may belong to different models.
Record Structure
cetmix_tower_model
YAML field type: String
Odoo model name.
Odoo model names are translated to YAML model names using the following rule: cx.tower.model.name
→ model_name
.
List of supported models
This list can be extended in custom modules by inheriting from the cx.tower.yaml.mixin
model. Check the Entity Diagram for the model relations.
Invalid model name
If the model name is invalid, the record will not be imported.
Example:
cetmix_tower_model: command
reference
YAML field type: String
Unique identifier of the record. If not specified, it will be generated automatically.
Example:
reference: add_user_to_docker_group
Missing reference
If no reference is provided, the record will be created each time the file is imported. This may result in multiple copies of the same record being stored in the database.
Base Odoo Fields
Char
YAML field type: String
.
Example:
name: Add user to "docker" group
Text
YAML field type: String
.
Example:
code: |-
{% if tower.server.os == "Debian 11" %}
/usr/sbin/usermod -a -G docker {{ tower.server.username }}
{% else %}
usermod -a -G docker {{ tower.server.username }}
{% endif %}
Integer
YAML field type: Number
.
Example:
priority: 1
Float
YAML field type: Number
.
Example:
percentage: 100.0
Boolean
YAML field type: Boolean
.
Example:
active: true
Date
YAML field type: Date
.
Example:
date: 2021-01-01
Datetime
YAML field type: Date
.
Example:
datetime: 2021-01-01 12:00:00
Selection
YAML field type: String
.
Odoo Selection
field values are represented in the YAML file by selection keys.
For example, the following Odoo field:
use_sudo = fields.Selection(
string="Use sudo",
selection=[("n", "Without password"), ("p", "With password")],
help="Run commands using 'sudo'. Leave empty if 'sudo' is not needed.",
)
Will be represented in the YAML file as:
use_sudo: p # "p" is the key for the "With password" selection value
Relational Fields
Supported relational fields:
Many2many
Many2one
One2many
Relational fields are represented in YAML in two ways:
Reference mode
Record is represented as a reference or as a list of references.
This mode is used when the related record(s) already exist in the database and there is no need to import it again.
Example:
tag_ids:
- reference: docker
- reference: system
Exploded mode
Each related record is represented as an entire record or as a list of entire records.
This mode is used when the related record(s) don't exist in the database or need to be updated.
Example:
tag_ids:
- reference: docker
name: Docker
color: 4
- reference: system
name: System
color: 1
Entity Diagram
The entity diagram is a visual representation of the YAML file structure.
- command
- tag # Tags assigned to command
- variable # Variables used by the command
- os # Operating systems associated with the command
- plan # Child plan executed by the command
- file_template # Template used to upload file from the command
- plan
- plan_line # Lines of the plan
- command # Command executed in the plan line
- plan_line_action # Actions depending on command output
- variable_value # Variable values set by the action
- tag # Tags assigned to the plan
- server_template
- variable_value # Configuration settings
- shortcut # Shortcuts to quickly trigger actions
- tag # Tags for categorization
- os # Default operating system
- server_log # Logs associated with the template
- plan # Plans executed when server is created/deleted
- file_template
- tag # Tags related to the template
- variable # Variables used in template
- variable
- variable_option # Available options (dropdowns)
- variable_value # Assigned values
- variable_value
- variable # Inline variables used in variable values
- key # SSH key or Secret
- os # Operating system
- tag # Global tagging entity
- git_project
- git_source # Sources
- git_remote # Source remotes